Second, when you have a regex using a (?:...) modifier, anything between the question mark and colon acts as a local switch unless it's after a -, in which case, it serves to negate a switch that's been applied to the entire regex. In this case, the /x switch (or modifier, if you prefer) at the end of the regex has the regex ignore unescaped whitespace, which you don't have in your first regex. As a result, your /x switch serves no purpose in this regex, and would be negated by the ?-x: construct, in any event.
The reason why the second regex does not match is because it's trying to match "#commenthere" (note the lack of spaces). Since they don't appear in your target text, you get no match.
Hope this helps.
Cheers,
Ovid
Update: I'm a moron. I need to think about this one a bit more. It's a lot trickier than I first thought. Now that I have a better idea of what you are doing, this does look like a bug. Changing ?-x: to ?: makes it work, but (?-x:...) is supposed to be local.
P.S. I am using 5.005 (ActiveState on WinNT)
In reply to (Ovid) Re: codem/(?:-x pattern) #comment /x bug?/code
by Ovid
in thread codem/(?:-x pattern) #comment /x bug?/code
by dcorbin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |