Reputation: 11676
I'm using AS3, but the silent fail is probably to do with the expression itself.
/(\w*'?\w*'?)||([,".-])/g
In Sublime Text 2 using this regex highlights exactly what I want (I run it without the forward slashes and the g). The desired matches are basically any word, a word with an apostrophe in it (or at the end), or some simple punctuation (commas, double-quotes, periods and hyphens).
When running in AS3 it seems to choke. It either just matches the first word it comes across (even when I've specified the global indicator) or it just ignores the punctuation regex.
Can anyone see anything wrong with this regex? Does AS3 get funky with ||
operators in regex?
Upvotes: 0
Views: 84
Reputation: 33928
There is no ||
operator in regex, there is |
. ||
will match the empty string, thus will not try to match anything further.
You could try an expression like this instead:
\w+(?:'\w+)?'?|[,".-]
Upvotes: 1