Creating hashtags only, nothing else

I am using this preg_replace to create hashtags twitter style:


$text = preg_replace('/(^|\s)#(\w*[A-Za-z-_]+\w*)/', '<a href="?query&search=$2">#$2</a>', $text);

Code (markup):
The problem is it creates hashtags from everything else that has a # sign. So when someone enters an address. i.e.: Some St. Suit #b75 that b75 will become a hashtag.

Sounds like an impossible task to tell it to differentiate between a real hashtag and something that is not.

What's even worse, if it finds...

Creating hashtags only, nothing else

from PHP http://ift.tt/295t9qB
via IFTTT
Previous
Next Post »
Thanks for your comment