Say I wish to find every iteration of orange
that is not preceded by apple and
using RegEx. I also want this to work for the respective plurals.
Here's a list of what should and shouldn't be valid.
orange - valid
oranges - valid
an orange - valid
apple and orange - invalid
apple and oranges - invalid
apples and orange - invalid
apples and oranges - invalid
The code I've written to make this possible so far is the following.
(?<!apples? and )oranges?
When I test it, I receive an error, tracing back to the optional s
character, after apple
. Regex101 describes the error as the following.
Lookbehinds need to be zero-width, thus quantifiers are not allowed.
Why is this? How can I solve this problem?