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(?<!^)|(jack|james))(?:\W+\w{1,3})*\W+(\w{4,})(?=(?:(?!\1).)*?(?!\1)(jack|james))
/
gm
Input 1
New
james was playing with jack yesterday jack was playing with james yersterday jack and james are best friends james will be helping jack with his homework yesterday, james come over jack's house