Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
r"
\b(?:apples|pears|bananas)(?:(?:\s+(?:or|and)\s+|\s*,\s*)+(?:apples|pears|bananas))*
"
gmi
Input 1
1
apples, pears, bananas are fruit pears, apples, and bananas are in the fruit basket you can use bananas, pears, and apples in a fruit salad he also likes pears, bananas, and apples for a snack she likes cheese for a snack but also apples or pears
Substitution
[\g<0>]
apples, pears, bananas are fruit pears, apples, and bananas are in the fruit basket you can use bananas, pears, and apples in a fruit salad he also likes pears, bananas, and apples for a snack she likes cheese for a snack but also apples or pears