I have this code in C#:
string data = "something ... 1,000 anything 20,000 other thing...";
string pattern = @"[0-9]+([\,|\.][0-9]{1,})*([\.\,][0-9]{1,})?";
MatchCollection collection = Regex.Matches(data, pattern);
foreach (Match item in collection)
{
Console.WriteLine("{0} - {1} - {2}", item.Value, item.Index, item.Length);
}
Console.WriteLine();
Console.WriteLine("End!");
Console.ReadKey();
... and I tried to convert it in C++ (native code, without .net assemblies), so I get something like this:
void main()
{
string data = "something ... 1,000 anything 20,000 other thing...";
regex pattern("([0-9]+([\\,|\\.][0-9]{1,})*([\\.\\,][0-9]{1,})?)");
const sregex_token_iterator end;
for (sregex_token_iterator i(data.begin(), data.end(), pattern); i != end; ++i)
{
std::cout << i->str() << "-" << i->length() << std::endl;
}
cout << endl << "End!";
fflush(stdin);
getchar();
}
So, how can I get the index of the match?