in reply to Re: Re: Regexp, match the nearest verb.
in thread Regexp, match the nearest verb.

Ah. What happens is that you still get the first match in the string. In this case, that's the match starting at "<samp>wants VB</samp>" (what's the `*' doing after `VB)' in your regexp, anyway?). You could use greediness to hit the last match in the string:

$sentence =~ /.*(\w+\sVB)(.|\n)*?($phrase)/
But that still doesn't guarantee "closenessest", just "lastness".

Your alternative is to look up and use sexegers for this second task. You will find much information on this very site...


PS. Please try to format your writeups so we can read them...