Yes it should - you haven't anchored the string.  If my memory serves me 
correctly, the engine sees that "rno" of supernova matches the first three 
tokens in the pattern.  The engine then sucks in "va" to match the next 
two tokens (.?.?) and fails because the v is already used.  But, since the 
? operator was used, the engine backtracks once, then twice and sees that 
"rnov" will match properly.  Finally, it finds the "a" on the end and 
returns positive.

If you were to anchor the expression with a ^, or change .?.? to .., it 
will behave as you expect.


Mik Firestone
Pinky, are you pondering what I am pondering?
Well, I think so Brain, but if we didn't have ears, we would look just 
like weasels.

Martin Weinless <[EMAIL PROTECTED]>
06/07/01 11:25 AM

        To:     <[EMAIL PROTECTED]>
        Subject:        regexp question


This is probably not a true beginners question - it refers to an example
that I use in class when we discuss regexps.

Here is the problem:

take the regexp '.n+..?.?v*.'

By all that is sacred, if we use the string 'supernova', there should be
no match since there are too many characters before the 'n'

However, any regexp checking code will report a match.

Any ideas/comments/etc.


Marty W.

WINDOWS: 32 bit extensions and a graphical shell for a 16 bit patch to an
8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can't stand 1 bit of competition.

Reply via email to