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
/
(cat(?:(?!dog).)*cat)|(dog(?:(?!cat).)*dog)
/
gm
Input 1
1
New
cat cat cat dog The cat chased another cat The cat chased another dog The cat chased the dog after the cat had chased another cat The cat chased the dog after the cat had chased another dog The cat chased the cat, and another cat chased, well – another dog The cat chased the dog, and another cat chased, well – another dog dog dog dog cat The dog chased another dog The dog chased another cat The dog chased the cat after the dog had chased another dog The dog chased the cat after the dog had chased another cat The dog chased the dog, and another dog chased, well – another cat The dog chased the cat, and another dog chased, well – another cat
Extraction
cat cat cat dog The cat chased another cat The cat chased another dog The cat chased the dog after the cat had chased another cat The cat chased the dog after the cat had chased another dog The cat chased the cat, and another cat chased, well – another dog The cat chased the dog, and another cat chased, well – another dog dog dog dog cat The dog chased another dog The dog chased another cat The dog chased the cat after the dog had chased another dog The dog chased the cat after the dog had chased another cat The dog chased the dog, and another dog chased, well – another cat The dog chased the cat, and another dog chased, well – another cat