I'm trying to write two functions:
- first method tests for a match in a string (like test())
- second method replaces keywords
Simply regex (like \bkeyword\b) works, but it replaces keywords inside HTML tags (e.g class, alt) and URL anchors. How should I do this? I can not use JavaScript libraries.
EDIT: I would like replace only first match and only match on exact-matches.
Thanks