Okay so I am horrible with regular expressions and need some help here. I’ve found this code to match a twitter username:
'/(?<=^|\s)@([a-z0-9_]+)/i
This works in most cases, except when a HTML tag is placed before the @username, example:
<p>@username</p>
That’s a problem for me since it will happen with what I’m doing.
Then there is this, which works, but also detects email addresses, which isn’t what I want:
/^[A-Za-z0-9_]+$/
Any ideas?
If the html tag ending
>is the problem, add it to your lookbehind group: