Im currently working a lot with regular expressions and one expression i am search for is a setup like this:
regex r("a\\s([+*/&|^-\%]*|[<>][<>])+="); // % currently unvailable due to missing escaping
smatch m1;
string str = "a++; a--; a += c; a -= c; a *= 3; a /= c; a = c; a %= c + 3; a &= c; a |= c; a ^= c; a <<= c; a >>= c; a <= 3; a >= 3;";
This works for the string perfectly, except for the percentage sign. If the percentage sign is included in the first block brackets in the r regex, it throws "std::regex_error what(): Invalid range in bracket expression."
It cant be escaped with the \ frontslash. I read that it can be escaped with another percentage sign and while that stops the error from popping up, it also now doesnt find the "a %=" either and is therefore useless to me.
Hope anyone has an idea how this can be accomplished, i googled a lot and looked here at Stack Overflow but i couldnt find a solution for this yet.