I am trying to create a proper regular expression to find all anchors in my project with Eclipse File Search.
What I’m looking for:
<a href="some.url" onclick="some onclickHandler">
What I want to accomplish is finding all anchors without an onclick and add it when needed.
Thanks for your help!
You can use the regex
<a href="\S+"((?!onclick).)*>. It will find all links without the onclick pattern.Short explanation for the interesting part
((?!onclick).)*:?!onclickis a Zero-width negative lookahead. This means the regex engine will match if it does not contain the word onclick. The surrounding(and.)*tells the regex engine, that the onclick exlusion can be surrounded by any other character.