In the following example, how could I match an X number of characters before and after (myword1 myword2):
word1 word2 word3 myword1 myword2 word4 word5 word6
Matching after is easy with curly braces: (myword1 myword2)(.+?){10} – but how could I match the preceding 10 characters before (myword1 myword2)?
I tried (.+?){10}(myword1 myword2), but that exceeded the memory limit.
>Solution :
You could use:
.{10}: match any character 10 times
So your expression becomes:
.{10}(myword1 myword2)
And the match is: rd2 word3 myword1 myword2