How to match !x but not !!x in JS regex?

Posted by mpeterson on Stack Overflow See other posts from Stack Overflow or by mpeterson
Published on 2010-06-02T13:30:41Z Indexed on 2010/06/02 13:34 UTC
Read the original article Hit count: 138

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex