b4swine has asked for the wisdom of the Perl Monks concerning the following question:
I want to regex to find the word 'cat' which are not immediately (with perhaps whitespace) followed by the word 'dog', so that it should match 'we have catnip for sale' and 'my cat eats dogs' but not match 'I sell hot cat dogs'.
The regex I could come up with was: /cat *([^d]|[^ ][^o]|[^ ].[^g])/
But for a longer 'dog', this would be a pain. Looking for a better solution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: search for 'cat' not followed by 'dog'
by haukex (Archbishop) on Jan 28, 2019 at 19:18 UTC | |
|
Re: search for 'cat' not followed by 'dog'
by stevieb (Canon) on Jan 28, 2019 at 19:24 UTC | |
by AnomalousMonk (Archbishop) on Jan 28, 2019 at 20:15 UTC | |
by stevieb (Canon) on Jan 28, 2019 at 20:31 UTC | |
by haukex (Archbishop) on Jan 29, 2019 at 08:57 UTC |