Regexp matching hashtags not wrapped in html tags
I want to make regexp match of hashtags started by @ or #, and not wrapped
in html anchor tag. My expression: (@|#)([a-zA-Z_]+)(?!<\/[a]) doesn't
work, because in text:
<p>@john Olor it amet, consectetuer adipiscing elit.
Aenean commodofadgfsd
<a class="autocompletedTag" href="#" data-id="u:2">@john_wayne</a></p>
Matches @john and @john_wayne, but I don't want to match @john_wayne.
<p><a class="autocompletedTag">@john</a> Olor it amet, consectetuer
adipiscing elit.
Aenean commodofadgfsd
<a class="autocompletedTag" href="#" data-id="u:2">@john_wayne</a></p>
How can Ido this?
Examples
In code :
<p>@john @kate <a>@royal_baby</a> #england <a>#russia</a></p>
I want to match @john, @kate and #england, but not @royal_baby and #russia.
In this code:
<p>#sale #stack #hello <a>@batman</a> #avengers <a>#iron_man</a></p>
I want to match #sale, #stack, #hello and #avengers, but not @batman and
#iron_man.
No comments:
Post a Comment