Reputation: 15
Wondering any regular expression can do that, e.g. I want to find whether foo is inside a quote pairs (no matter single or double quote):
"foo" <- true
"'foo'" <- true
"it's foo" <- true
"abc". Foo. "def" <- false
abc'foo <- false
f"oo" <- false
Upvotes: 0
Views: 108
Reputation: 40573
In general, no. This kind of stuff is not in the domain of regular languages as you need some sort of memory to track the occurrences of quotes.
However modern regexps are more powerful then simple regular languages, so it might be possible. But I'd go for something like this:
Use more then a boolean if you care about single and double quotes.
Upvotes: 1