I have an issue with a regex expression and need some help. I have some expressions like these in mein .txt File:
19 = NAND (1, 19)
regex expression : http://rubular.com/r/U8rO09bvTO
With this regex expression I got seperated matches for the numbers. But now I need a regex expression with an unknown amount of numbers in the bracket.
For example:
19 = NAND (1, 23, 13, 24)
match1: 19, match2: 1, match3: 23, match4: 13, match5: 24
I don't know the number of the numbers. So I need a main expression for min 2 numbers in the bracket till a unknow number.
By the way i'm using c++. @ Martjin Your first regex expression worked very well thanks. Here my code:
boost::cmatch result;
boost::regex matchNand ("([0-9]*) = NAND\\((.*?)\\)");
boost::regex matchNumb ("(\\d+)");
string cstring = "19 = NAND (1, 23, 13, 24)";
boost::regex_search(cstring.c_str(), result, matchNand);
cout << "NAND: " << result[1] << "=" << result[2] << endl;
string str = result[2];
boost::regex_search(str.c_str(), result, matchNumb);
cout << "NUM: " << result[1] << "," << result[2]<< "," << result[3] << "," << result[4] << endl;
My output: NAND: 19=1, 23, 13, 24 NUM: 1,,,
So my new problem is i only find the first number. The result is also in complete opposite with this solution: http://rubular.com/r/nqXDSuBXjc