javascript - Negative look-around -


The following regexp is incorrect - anyone can help find all :-) that "ignore me" Not in front? I do not need such a regexp before the word limitations can confuse things.
thanks

  & lt; Script type = "text / javascript" & gt; Function regexTest (string, highlight) {document.write ('& lt; hr & gt;') document.write (string) document.write ("["] document.write (string.match (/ \ b (( ?!)) \\ \\ \)) \ B / GI! = Faucet; Document.write ("]?" + Emphasize);} RegexTest ("1. This is the first string :-)", true); RegexTest ("2. :-)", is true) regexTest ("3. another string :-)" here, true); RegexTest ("Ending a sentence with :-)", true); RegexTest ("5. Please ignore me :-)", false); & Lt; / Script & gt;  

If you want to match to : -) That is not by predecessor "please ignore me", you will need lookahead instead of a look-up (? & Lt;!) (?! ...) . However, JavaScript does not help LookWinds.

So what can you do with (\ bplease ignore me \ s *) ?: - \) And then, matches, check whether the capturing group < Code> $ 1 is empty.


Comments