Hello to all. I am trying to parse a string using.

#include <regex> using namespace std; int main() { string input = "((true);(false);(0))"; regex regular_exp("\("); string replace = "\)"; res = regex_replace(input, regular_exp, replace); cout << "REPLACED - " << res << endl;` } 

produces this: Aborted. at abort.c. function __GI_abort () on line 89 terminate called after throwing an instance of 'std :: regex_error' what (): regex_error

Help to understand why, and how to solve the problem!

    1 answer 1

    Little shielding, same string.
    And in the string for replacement, it is not needed at all.

    http://ideone.com/cKckAf

     #include <regex> #include <iostream> using namespace std; int main() { string input = "((true);(false);(0))"; regex regular_exp("\\("); string replace = ")"; string res = regex_replace(input, regular_exp, replace); cout << "REPLACED - " << res << endl; }