Hrm. Actually, that's what the \G is for. It anchors to the place that the last /g match matched (sorta like the ^ anchor) and defaults to the start of the string (if no previous matches were made). So, theoretically, the first RE shouldn't match at all until after the second RE has matched at least once. And that's my problem: it isn't working that way.
Also, there are several other RE's in the actual tokenizer so alternation isn't really an option.
I built my example more or less out of the snippet provided here under the section about the /g modifier, and the other parts of the "lex-like scanner" (as it's called in the perlop page) work just fine. The problem seems to be totally with the \\? (specifically the ? part).
I do thank you for the suggestion though. :-)
(PS: Just so it's clear: the idea is to match an identifier preceded by an ampersand and, optionally, a single backslash. The characters infront of the ampersanded identifier (except for the optional backslash) should be matched by the second RE, effectively breaking the string into "tokens". The actual routine is a bit more complicated and has a lot of other, unrelated code that I took out for (sanity|readibility)'s sake.)
(PPS: Okay, so I used a dollar-sign in the code snippet. It's an ampersand in the actual routine, I promise. :-) And it doesn't matter anyway.)
bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.
|