Highlite words from searchstring
        Posted  
        
            by Bundy
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Bundy
        
        
        
        Published on 2010-03-08T11:25:29Z
        Indexed on 
            2010/03/08
            14:06 UTC
        
        
        Read the original article
        Hit count: 276
        
Hi,
I wrote a little search script for a client, it works and words get highlited, BUT...
Imagine this situation:
search term: test
found result: Hello this <a href="/news/this-is-a-test">is a test</a>
In this example both 'test' in the href part and between the <a> tags get highlited, breaking the link.
How could I prevent this?
Edit:
So this is what I need: A regex replace function that replaces all matched search strings EXCEPT the ones that are located inside a href attribute
Greets, nick
© Stack Overflow or respective owner