I'm trying to match @
's that are preceeded by nothing or whitespace like in the following example:
@one
@two
who@three
/@four
My approach is (^|\s)@
, but this captures one two three four
. \s@
only captures two
. How do I get one two
, without getting three four
?
If it's relevant, all @
's are succeeded by a letter.
How about ^\s*@
? That is, start of line followed by zero or more whitespace then @. (Note, different laguanges have different regex rules)