hash tags?
letsforum Offline
Junior Member
**
Posts: 36
Joined: Sep 2013
Post: #1
hash tags?
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']);


Internet marketing and SEO forum - http://letsforum.com
(This post was last modified: 08-20-2015 01:05 PM by letsforum.)
08-20-2015 01:03 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: hash tags?
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.

My Blog
09-01-2015 04:52 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: