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
/
(?:\G(?!^)|^(?=.*string3)).*?\Kstring1
/
gm
Input 1
1
New
This is line string1 This is line two with string1 and string3 string1 This is line two with string1 string1 and string3 This is line three with string3 This is line string3 with string1 and string1
Substitution
string2
This is line string1 This is line two with string1 and string3 string1 This is line two with string1 string1 and string3 This is line three with string3 This is line string3 with string1 and string1