July 31st, 2011, 09:37 PM
Need help targeting words starting with @ and no spaces/periods/commas after
Hi I've used regex briefly in the past, not very often or complicated. I need help targeting words starting with @ and no spaces/periods/commas after
I'm using preg_match_all to get all of these items but i believe my regex expression is the issue.
So the string: "@hello devshed @hi"
should only return in an array hello and hi.
This is what i have now:
preg_match_all('/(@)(.*)[^\S]/', $string, $matches, PREG_SET_ORDER);
August 1st, 2011, 08:56 AM
I've just helped someone in the PHP forum with a similar situation
here's an excerpt:
$str = "Hello @kitty, i was talking to @northie about you. Thanks @sky.";
$pattern = "/\@[A-Za-z0-9]+/";
Here's the full link: http://forums.devshed.com/php-develo...er-836590.html
 => Array
 => @kitty
 => @northie
 => @sky