I have these strings, I want to return regex confirm those patterns.
NS::varible.child // OK
variable.child // OK
NS:variable.child // NO MATCH
::variablename.child // OK
:variablename.child // NO MATCH
_variablename.child.x // OK
5variablename.child.x // NO MATCH
I want C++ variable name match without -> operator and template<>
I have come up with this regular expression.
[a-z\_:{2,2}A-Z][a-z\_A-Z0-9\.:{2,2}]*
:{2,2} doesn’t seem to be doing what I want. It accepts a single colon too.
How do I check exactly two colons? Even better a regex to match C++ variable constructs?
One of the options:
Play with it online on Rubular.