Reputation: 31800
Is there a way to specify that a regular expression should not contain a match of another regular expression?
Which regular expression (given here in Javascript-style syntax) would correspond to the regular expression /(artwork|sheep|cattle|book|literature)(s)/i
, but not containing matches of /(sheep|cattle|artwork|literature)(s)/
?
Upvotes: 0
Views: 107
Reputation: 52161
if /books/
is not the answer then perhaps try with negative look ahead.. like this
=> /(?!(?:sheep|cattle|artwork|literature)(?:s))(artwork|sheep|cattle|book|literature)(s)/
>> re =~ 'books'
=> 0
>> re =~ 'bookxs'
=> nil
>> re =~ 'sheep'
=> nil
>> re =~ 'cattle'
=> nil
>> re =~ 'test'
=> nil
Upvotes: 1