From: David Alan Black Date: 2004-05-12T20:18:54+09:00 Subject: Re: Strange regexp behaviour in gsub Hi -- Joel VanderWerf writes: > 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 Whoops :-) > 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 Yes, you're right, though I'm driven to find something that doesn't involve repeating the 'b'. Current iteration: /a(.*\W.*)?b/.match("a%xb") # => # (possibly with *?'s instead of *'s, depending on the OP's needs) David -- David A. Black dblack@wobblini.net