I just want to know if the rosy regular expression has a non-matching operator, like !~ In perl. I find it inconvenient to use (?!xxx) or (?<!xxxx) because you cannot use regex patterns in the xxx part.
!~
(?!xxx)
(?<!xxxx)
xxx
Yes !~ Works just fine - you probably thought it wasnโt because it is not on the Regexp documentation Regexp . However, this works:
Regexp
irb(main):001:0> 'x' !~ /x/ => false irb(main):002:0> 'x' !~ /y/ => true
AFAIK supported (?! Xxx):
2.1.5 :021 > 'abc1234' =~ /^abc/ => 0 2.1.5 :022 > 'def1234' =~ /^abc/ => nil 2.1.5 :023 > 'abc1234' =~ /^(?!abc)/ => nil 2.1.5 :024 > 'def1234' =~ /^(?!abc)/ => 0