Question

I need a regular in expression in PHP that I can plug into preg_match_all and find if an @ sign and any character number or letter follows right after that.

So if I put

@patrick hello there

it will come up true, if I put in

"I saw her @ the mall"

it will be false.

Thank you

Was it helpful?

Solution

An at sign followed by at least one letter, number, or underscore:

/@\w+/

OTHER TIPS

Great site on Regex: http://www.regexlib.com/CheatSheet.aspx

as well as http://www.regular-expressions.info/ as the fellow below me pointed out!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top