Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(begin[\s\S]*?\([\s\S]*?)foo([\s\S]*?\)[\s\S]*)
/
Input 1
1
New
begin foo even spaces and maybe new line( some text only replace foo foo bar foo, keep the rest ) some more text not replace foo here
Substitution
$1abc$2