I have a C++ regex to search for characters inside square brackets, for instance if the string is x[7:0], I want to return 7:0. This is what my regex looks like -
std::regex reg("\[(.*?)\]");
When I compile (g++) I get the following warning -
../fixedPointFormatter.cc:30:18: warning: unknown escape sequence: ']' std::regex reg("[(.*?)]"); ^~~~~~~~~~~
The following returns nothing...
if (regex_search(arg, matches, reg)) {
for (int i=1; i<matches.size(); i++) {
cout << matches[i] << endl;
}
}
Can someone help identify what is wrong with this?