Good day,
I have recently started working with regex (in java) and have stumbled onto a problem I require some assistance/guidance.
I am looking to find words of a certain length (in this case 4 characters long or more) between two words jack and james.
The following is the text I am using to test my regex against.
james was playing with jack yesterday (line 1)
jack was playing with james yersterday (line 2)
jack and james are best friends (line 3)
james will be helping jack with his homework (line 4)
yesterday, james come over jack's house (line 5)
What I hope to achieve is the following
playing with(line 1)
playing with(line 2)
no matches(line 3)
will helping(line 4)
come over(line 5)
I have come up with the following
(?<=james)(.*)(?=jack)|(?<=jack)(.*)(?=james)
But this particular regex, returns all characters between the two words. I also tried the following unsuccessfully (as well as many others before frustration started taking over). Also, I omitted
(?<=james)(\\b\w{4,}\\b)(?=jack)|(?<=jack)(\\b\w{4,}\\b)(?=james)
Any guidance would be greatly appreciated.
Sincerely