MyBB Hacks

Full Version: hash tags?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi could you help me please?

I am using this regular expression to match hash tags in the post:

Code:
/#([A-Za-z0-9]+)(?=\s|\Z)/


It works but of you add a special character to the end or inside the tag it stops working!

How to make this:

Code:
/#([\w]+)/i

not to grab font color #fff; or color from BBcode [font=#fff]

Code:
$post['message'] = preg_replace('/#([A-Za-z0-9\.\,\?]+)(?=\s|\Z)/', ' [url='.$mybb->settings['bburl'].'/hashtag/\1]#\1[/url]', $post['message']);

Doing this properly is a fair bit more difficult than a simple regex.
Check the MyBB code and see the elaborate hacks needed to get smileys working correctly, for example.
Reference URL's