SuperBlue Posted August 12, 2008 Share Posted August 12, 2008 var CregExp = new RegExp("\\.*" + terms[x] + "\\.*(?!\<a href\=\>.*\<\\a\>) ", "gi"); The above RegExp is suposed to match everything else but the links, i tried using the "?!" as suggested by the reference, but either i'm doing it wrong, or it just doesn't work. The whole idea of using JS to do this, is to avoid having to use PHP for something the browser should be fully capable of, I.E. Highlighting search terms. I have managed to create a fully functional highlighting code, but now i would like it to exclude a pattern from its matches, any idea how to complete this? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 12, 2008 Share Posted August 12, 2008 I'm not sure, but I would think that regex would match your terms ONLY if they are not followed by a link that matches that negative look-ahead. I think the way you would have to do this is to negate the match for the <a> and </a> tags around your match terms, instead of at the end. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.