In regular expression, how do I look for matches that start with an @symbol? The symbol cannot be in the middle of a word (link in an email address).
For example, a string that looks like this:
@someone's email is [email protected] and @someoneelse wants to send an email.
The expression I'd use is /^@[\w]/g
It should return:
@someone's
@someoneelse
The expression I use doesn't seem to work.
You can utilize \B which is a non-word boundary and is the negated version of \b.
var s = "@someone's email is [email protected] and @someoneelse wants to send an email.",
r = s.match(/\B@\S+/g);
console.log(r); //=> [ '@someone\'s', '@someoneelse' ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With