Given the following text:
This is!!xa simple string!xpattern
I would like to get a regexp that matches the !x
that's between "string" and "pattern" but not !!xa
that's between "is" and "a".
This regexp is to be used inside a string split()
.
I have tried several combinations but I cannot get a regexp that meets my needs. Perhaps my expression is not so regular after all =)
Thanks in advance!
EDIT:
SOLUTION
Just to state clear the solution is going to be:
s.replace(/(([^!])|^)!x/g,'$1SOME_MAGICAL_STRING').split(/SOME_MAGICAL_STRING/)
Thanks for the solution idea to both jvenema and Amarghosh. And also to everyone that provided feedback too.