Hi,

On Fri, 21 May 2004, Matthias Keller wrote:

> Still writing some cool rules for my SA (and if they prove themself
> useful hopefully soon for everyone's SA) and I'm trying something like:
> match some word and if at some later position there's anything BUT this
> word, return true
>
> I'm thinking about something like this:
> /([a-z]) [^\1]/i
>
> This should for example match
> asdf fdsa
> asdf kdkd
> asdf asd
>
> but NOT
> asdf asdf
>
> Is that possible anyway?

Yes, but with a performance hit. Do you want:

   /([a-z]+)\s+(?!\1)/

      matches "asdf fdsa"
      matches "asdf kdkd"
      matches "asdf asd"
doesn't match "asdf asdf"
doesn't match "asdf asdfg"

or

   /([a-z]+)\s+(?!\1\b)/

      matches "asdf fdsa"
      matches "asdf kdkd"
      matches "asdf asd"
doesn't match "asdf asdf"
      matches "asdf asdfg"

AOL Keyword: negative look-ahead assertion. See 'perldoc perlre' for
details.

Handling case-insensitivity may be weird but probably doable.

hth,

-- Bob

Reply via email to