intersection in regular expression matches

Joined
Aug 18, 2006
Messages
1
Reaction score
0
Hi all,

Im trying to find the 3 preceding and following words for a search keyword in a textfile using the following expression:

(\w+) (\w+) (\w+)) \bkeyword\b (\w+) (\w+) (\w+)

The problem is if the keyword is detected as one of (\w+)'s then the regex engine will bypass it and will not be matched by the regular expression.

For example if I have the following sentence and I search for the keyword very is will be detected only once because the second very will be included in the first match:

I am really very happy and very excited as well.


Any idea on how to get all the matches of a keyword in this situation?

Thanks
Roberto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top