I need php to find any word in a string that begins with an @ symbol. It has to be by itself:
For instance:
@myname = match
asdf@myname = not a match
@ myname = not a match
@@ = not a match
@@myname = not a match
Any ideas?
php to find @ symbol
Moderator: General Moderators
Re: php to find @ symbol
Code: Select all
preg_match("/(^@[^@\s]+.*?)$/",$string,$matches);
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: php to find @ symbol
You will need to define what a "word" is for you. The suggestion of the previous poster will also match strings like:Citizen wrote:I need php to find any word in a string ...
Code: Select all
"@~~~~"
"@abc,"
"@1ab2"