Regular Expression Help

Posted by JSteele1234 on Sun 03 Jun 2001 07:20 AM — 2 posts, 12,975 views.

USA #0
I noticed there's a thing to match specific words "^(Blah|Qaz|etc..)", but is there something like that that will make it NOT match to given words?
Australia Forum Administrator #1
Yes, there is. I quote from the file: RegularExpressions.txt that ships with MUSHclient:


Lookbehind assertions start with (?<=  for  positive  asser-
tions and (?<! for negative assertions. For example,

  (?<!foo)bar

does find an occurrence of "bar" that  is  not  preceded  by
"foo". The contents of a lookbehind assertion are restricted
such that all the strings  it  matches  must  have  a  fixed
length.  However, if there are several alternatives, they do
not all have to have the same fixed length. Thus

  (?<=bullock|donkey)

is permitted, but

  (?<!dogs?|cats?)

causes an error at compile time. Branches  that  match  dif-
ferent length strings are permitted only at the top level of
a lookbehind assertion.