MyBB Community Forums

Full Version: Regular extention?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working on hash tags but I have an issue?

I am parsing message with this:


$tweet = $message;
return preg_replace("/#([A-Za-z0-9_]+)(?=\s|\Z)/", '<a href="'.$mybb->settings['bburl'].'/hashtag/\1">#\1</a>', $tweet);
return $message;

This works but stops when the hashtag contains special character!

I am using this expression:


/#([\w]+)/i

It works great simply ignores the special characters but the problem is it also parses quotes, signature and codes.

How to make make this work?
(2015-08-19, 04:29 PM)marcus123 Wrote: [ -> ]
$tweet = $message;
return preg_replace("/#([A-Za-z0-9_]+)(?=\s|\Z)/", '<a href="'.$mybb->settings['bburl'].'/hashtag/\1">#\1</a>', $tweet);
return $message;

I don't have much experience with regular expressions but the above php code cannot be good, with 2 return stements after each other. However I suppose the 1st does the same as the 2-nd, when in the 1-sr return is replaced bby $message =