My code is to use regex match group for 5 thing this is my code :
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main(){
try{
string input("(66+89i)+(12+5i)");
regex re("([\\d]+)([+\\-]?[\\di]+)\\)([+\\-*=\\/!]+)\\(([\\d]+)([+\\-]?[\\di]+)");
smatch match;
if (regex_search(input, match, re)) {
cout << "x1 : " << match.str(1)<<endl;
cout << "y1 : " << match.str(2)<<endl;
cout << "operator : " << match.str(3)<<endl;
cout << "x2 : " << match.str(4)<<endl;
cout << "y2 : " << match.str(5)<<endl;
}
else {
cout << "No match is found" << endl;
}
} catch (std::regex_error r) {
cout<<r.what();
}
return 0;
}
when I run this code i get this error " Invalid range in bracket expression." how can i fix this ?
UPDATE : this code works in c++17, but in c++14 I get an error! in this compiler link is not work