Reputation: 979
I am using node.js and reading string for matching
</em><em>
The same string used in regex
var regex=new RegEx('<\/em><em>',"g");
I want to get two words before and after the matched string.
E.g.,
abc233 3344</em><em>abcd 3333
3333abcd 3444</em><em>3333 dkdkd
Any one assist me?
Thanks in advance.
Upvotes: 0
Views: 823
Reputation: 107287
You can use following regex :
/((?: |^)\w+){2}<\/em><em>(\w+(?: |$)){2}/gm
See demo https://regex101.com/r/fY2qE3/1
Upvotes: 2