Regular Expressions 101

Community Patterns

match x or y but not if z is present in a string

1

Regular Expression
PCRE (PHP <7.3)

/
^(?=.*(orange|apple))(?!.*box).*$
/
gm

Description

matches one or two words but excludes the string if a 3rd word is present

Submitted by Pushpesh Kumar Rajwanshi - 3 years ago