Simple regex - finding words including numbers but only on occasion -


i'm bad @ regex, have:

    /(@[a-za-z-]+)/ 

which finds words after @ symbol in textbox, need ignore email addresses, like:

    foo@things.com 

however finds @things

i need include numbers, like:

    @he2foo 

however finds @he part.

help appreciated, , if feel explaining regex in simple terms, that'd great :d

/(?:^|(?<=\s))@([a-za-z0-9]+)(?=[.?]?\s)/ 

@this (matched) regex ignores@this matches on @separate tokens tokens @ end of sentence @this. or @this? (without picking . or ?) , yes email@addresses.com ignored too.

the regex while matching on @ lets access what's after (like userid in @userid) picking regex group(1). check php documentation on how work regex groups.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -