mardi 10 octobre 2017

I want to print the numbers present in a string using regularexpressions(regex) IN C++ Language

I want to print the numbers present in a string using regularexpressions(regex) IN C++ Language My code is this, can anybody help me...

#include<iostream>
#include<string>
#include<regex>

using namespace std;
void main()
{
    string line="<has id='1235'> 2456 45 83 15 </has>";
    std::regex r("([0-9]+)+");
    cout << line << endl;
    std::smatch m;
    if (regex_search(line , m, r))
    {
       for (auto x:m)
           cout <<x << "\t";
    }
 }

I am getting output as :: 1235 5 but i need to get the output :: 1235 2456 45 83 15

Aucun commentaire:

Enregistrer un commentaire