# Sometimes I feel quite clever only for it to be demonstrated how I might have been overthinking things.
Smokey recently produced a function to automatically convert @-mentions to clickable links for micro.blog users.
His regex pattern is simple and works.
He takes a different approach to my hashtag linking function in that his is applied pre save thus changing the actual post content, whereas mine only impacts the output when viewed.
It's crazy how performing the same action at two different times (save vs display) requires such a difference in complexity of solution.
Note: his pattern doesn't work at display time.
I'm sticking to my method as I've only ever wanted the hashtags to be a feature when viewing the blog itself rather than when distributed via RSS, but it's been a good lesson.
Comments
# Dameon wanted a little more detail about setting up the hashtag function so I have updated my original hashtags repository on GitHub.
@colinwalker there are many ways to skin a cat, as the saying goes.
@PhoneBoy Indeed, it’s just surprising how doing the same thing at different points requires something totally different.
@colinwalker I think you're also trying to do a little more as well (auto linking hashtags). It wasn't clear from your post exactly what I needed to add to functions.php where, though. Can you point to more explicit instructions?
@PhoneBoy I’ll put both variants up on GitHub later when I get home.
@colinwalker cheers
Dameon wanted a little more detail about setting up the hashtag function so I have updated my original hashtags repository on GitHub.
@colinwalker Your regex is certainly more comprehensive than mine ;-) There are several edge-cases mine doesn't handle (most notably adjacent to HTML markup). I think it's neat how you can have your hashtags only linked on your site (where they make sense). But mostly I like how we're all sharing helpful code snippets and learning from each other here ?
@smokey I tried yours against a test post I have in draft and it worked perfectly. The difference between save and display requirements is crazy.
@colinwalker Wow, crazy indeed!