From: Joel VanderWerf Date: 2004-05-12T11:42:13+09:00 Subject: Re: Strange regexp behaviour in gsub David Alan Black wrote: > Hi -- > > Kristof Bastiaensen writes: > > >>I was thinking more about something like variable-width look-between :-) >>Meaning for example a(?^\w+)b would match any a(.*)b if (.*) is >>not equal to (\w+) > > > For that particular case you can use \W (opposite of \w): > > /a\W*b/ # a + zero or more non-\w + b Not quite the same: /a\W*b/ =~ "a%xb" # => nil It sounded like the OP wanted an re that matched "a%xb", because "%x" is "not equal to (\w+)". Sort of like: /a(?!\w+b).*b/ =~ "a%xb" # => 0