Twitter Widget Pro
[resolved] [GIFT] Improved #hashtags regex to match accentuated characters (10 posts)

  1. Vivien Garcia
    Posted 3 years ago #

    Hi there
    First : thanks very much for this great plugin which helps me a lot.

    So I'm French and I use accentuated characters in hashtags. The original regex couldn't match with those hashtags, so I've tweaked it a bit.

    Regex is situated in : /[your_plugin_directory]/wp-twitter-widget.php at line 451 – in public function linkHashtags().

    Just replace the preg_replace_callback() regex :

    by this one :

    I'm not a programmer so I suppose this code isn't very nice and smart but I does the job for me.

    I hope it will help someone as it helped me. :-)


  2. Aaron D. Campbell
    Plugin Author

    Posted 3 years ago #

    Can you test this regex to see if it works as you expect:

    It should still account for all the characters you added as well as a few more. Let me know how it works and I'll try to incorporate it into the next version.

  3. Aaron D. Campbell
    Plugin Author

    Posted 3 years ago #

    This new regex is in 2.4.0 ... please download it and see how it works for you!

  4. Fabio.Gomez
    Posted 3 years ago #


    Thank you Vivien, it works like a charm.

    Aaron, same problem over here, with Spanish hashtags, I'm using the last version, 2.4.0, with the regex you had posted, and it doesn't work either.

    Thank you for such a great plugin.


  5. Aaron D. Campbell
    Plugin Author

    Posted 3 years ago #

    Can you link to some tweets that have characters that aren't working?

  6. Fabio.Gomez
    Posted 3 years ago #

  7. Aaron D. Campbell
    Plugin Author

    Posted 3 years ago #

    There was a u left off the end of the regex. /i should be /iu. I fixed it in version 2.4.1, so as soon as that propagates through the repository and you update this should be fixed.

  8. elimc
    Posted 2 years ago #

    This seems like it would be less complicated, and possibly more inclusive:


    You can test out regexp, here: http://gskinner.com/RegExr/

  9. Aaron D. Campbell
    Plugin Author

    Posted 2 years ago #

    There are characters that are not allowed in URLs that should be ignored when trying to match URLs. There are also characters that ARE allowed but are rarely used *in* URLs and are often used to delineate. Here are some samples that I'm trying to link as the user expects:

    1. I visited http://wordpress.org. You should too.
    2. I visited http://wordpress.org, said Alice.
    3. I visited http://wordpress.org; it prompted me to take action and get involved.
    4. Quote from http://wordpress.org: Code is Poetry
    5. WordPress (http://wordpress.org) is a great platform.

    In each of those the user really wants http://wordpress.org to be linked. They don't want the trailing character linked .,;:)

  10. elimc
    Posted 2 years ago #

    I was using my regexp for hashtags and not links, but I understand your concern. If someone does:

    I went to the #store.

    There will be an issue. At the same time, under your current code, if someone did:

    I went to #7.11

    There will also be an issue . . . if I understand correctly. I know no one will use 7.11, but I couldn't think of another example. Anyway, the point is that I guess you have to pick and choose?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Twitter Widget Pro
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic