On Tue, Aug 08, 2000 at 12:30:25AM -0400, Rick Delaney wrote: > > Now, consider wanting to match the first number on a line, but only if it's > > not after XXX. That would be: > > > > /\d+|XXX\V/ > > It seems like the primary purpose of this is to abort the match attempt > when a certain condition occurs. If that is the case, I'd rather see > something like: > > /XXX\F|\d+/;# abort if XXX, else match digits > > where \F means fail. Here is the semantic f*ckup: \F means: do not let the REx engine to consider the other alternatives. Translating back to the REx semantic: SUCCEED. So \F means: succeed as far as the match is concerned, but report failure to the "caller". (\FINISH) This is a very useful concept indeed, but it may have many flavors. Say, re-denote the above flavor as \F{!*} (finish, and do not succeed anywhere). Then \F{.} (finish here and succeed) may be useful too: (?: A \F. | B ) C # \F. is \F{.} would be a shortcut for A | (?: B C ) (useful only if there are many more branches and/or levels of deepness). The most useful may be \F{!<} (FINISH, mark positions before this one as "failing", and restart the whole match). Since the positions before the given one are marked as "failing", the match will restart at the current position (as if pos() and \G .*? were present). Then one could match comments in C code without preprocessor commands by ' ( \\. | [^\\'] )+ ' \F{!<} | " ( \\. | [^\\"] )* " \F{!<} | /\* .*? */ Note that all these notions do not mention backtracking/NFA at all. They (kinda) mention forward-tracking of the start-of-match, but this mentioning may be eliminated by rewording. Ilya