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
/
(?<!\b(?:soy|almond)\s*(?:milk)?)\bmilk\b
/
gm
Input 1
"...almondmilk..." = no match "...almond milk..." = no match "...almond word(s) milk..." => matched ['milk'] "...almondword(s)milk..." => matched ['milk'] "...soymilk..." = no match "...soy milk..." = no match "...soy word(s) milk..." => matched ['milk'] "...soyword(s)milk..." => matched ['milk'] is combined with creamy soy and milk. a fruity and refreshing sip of spring, is combined with creamy milk. a fruity and refreshing sip of spring, "...milk...this is soy milk and regular milk"
Substitution
"...almondmilk..." = no match "...almond milk..." = no match "...almond word(s) milk..." => matched ['milk'] "...almondword(s)milk..." => matched ['milk'] "...soymilk..." = no match "...soy milk..." = no match "...soy word(s) milk..." => matched ['milk'] "...soyword(s)milk..." => matched ['milk'] is combined with creamy soy and milk. a fruity and refreshing sip of spring, is combined with creamy milk. a fruity and refreshing sip of spring, "...milk...this is soy milk and regular milk"