Someone help me out with a regular expression please.
What I want to match:
="..."
='...'
=...
="...'..."
='..."...'
but not:
="...'
='..."
I want to match a value, optionally enclosed in one of two parenthesis types (" or '). Both side should be terminated by the same type of parenthesis or nothing. The value itself may not contain parenthesis of the type it is opened or closed with. If it lacks outer parenthesis, it may not contain any parenthesis. I have come this far:
\=[\x22\x27]{0,1}([^\x22\x27]*?)[\x22\x27]{0,1}$
\x22 is " and \x27 is '
\= and $ is just for clarification. The actual borders are defined differently.
The 1st problem is, that the latter [\x22\x27]{0,1} should be equal to the initial [\x22\x27]{0,1}
2nd problem is, that the middle term [^\x22\x27] should be the negation of what the outer terms evaluate to.