email - Regex: How to match all occurrences of @something in a string -


i need find occurences of word prededed '@' character in way: @soemthing.

example:

string input = "@alias1 first email @alias2.com , email@alias3 along @alias4 disabled"

i want match @alias1 , @alias4 not @alias.com, or email@alias3

thanks

this should work...

(?<=^|\s)@\w+(?=\s|$) 

to explain, (?<=^|\s) positive lookbehind ensuring you're either @ beginning of string, or there's character of whitespace preceding match. , (?=\s|$) positive lookahead ensuring match followed either whitespace, or end of string.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -