I have to generate regex programatically. In this particular case, my regex object should correspond to the string: "([(+1)((+1))])((-1)(+1))*([(-1)((-1))])"
#include <bits/stdc++.h>
using namespace std;
int main()
{
regex r("([(<1)((<1))])((<1)(>1))*([(>1)((>1))])");
cout << (regex_match("<1>1", r) ? "YES" : "NO") << endl;
}
However, I am getting the match as false. Are the parenthesis being treated as matchable characters?
I think I have misunderstood regex syntax somewhere. I could not find any helpful material online having complex regex.
PS: I understand that this is a very clumsy regex for this problem. Any leads towards resources for simplifying regex will also be appreciated.
UPDATE: (updated code) https://ideone.com/8HAuEk