I have a (assumed well formed) regex expresion R. I want to test if the regex expression is just a single match (all letters, numbers, and escaped expressions) or could be swapped with anything else. This function, "HasWildCards", would work like this:
bool a = HasWildCards("asdf");//returns false
bool b = HasWildCards("asdf*");//returns true
bool c = HasWildCards("asdf[123]");//returns true
bool d = HasWildCards("asdf\\[123\\]");//returns false
I am using boost::regex, if that helps at all. I was thinking of checking if the regex expression matches something like this:
(^(([\[\^\$\.\|\?\*\+\(\{\}])))?(\\[QEdwsDWSbAZzB])?([^\\][\[\^\$\.\|\?\*\+\(\)\{\}])?
I've tested this on a few expressions (using the RegexTest tool of grepWin)
So non-escaped regex symbol to start, non-escaped flag,non-escaped regex sumbol in body. Is there an alternative? Did I screw something up? Is there a better way?