So i have this html:
<img src="images" alt="alt" />
alt <a href ="http://google/something">alt</a>
test hallo world monkey
<p>alt</p>
and a dictionary containing
{alt, test, hallo, world, monkey, something}
so i need a regex or another method to replace words that are not within a A tag or a img tag
I have tryed the following regex:
(?<![a-zA-Z帿ŨÆ])alt(?![a-zA-Z帿ŨÆ])^*(?!=)$
You could use regex and do a negative lookahead and lookbehind for letters:
in your example this would look like this:
My first intend was to do a positive search for whitespace characters, but then I thought of punctuation and stuff like this, a keyword is still a keyword if it has a .,!? at the end, right? So lookaheads and lookbehinds essentially check if something preceeding or succeeding your keyword, without replacing these, too.