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
/
(?<=^|\bfoobar\b)(?!foobar\b)(.*?)(?=\bfoobar\b|$)
/
gs
Input 1
1
New
notfoobarfoobarnot this should be highlighted, and same with this. but any sentence that has the word foobar shouldnt be, and same for any regular sentence with foobar <-- like that foobar beginning a sentence should invalidate the entire sentence, same with at the end foobar only foobar, and nothing else of the sentence more words here more irrelevant stuff to highlight and nothing of the key word what about multiple foobar on the same foobar line?
Substitution
notfoobarfoobarnot this should be highlighted, and same with this. but any sentence that has the word foobar shouldnt be, and same for any regular sentence with foobar <-- like that foobar beginning a sentence should invalidate the entire sentence, same with at the end foobar only foobar, and nothing else of the sentence more words here more irrelevant stuff to highlight and nothing of the key word what about multiple foobar on the same foobar line?