Page 1 of 1

Regexep Plugin

Posted: Fri Jun 03, 2016 9:03 am
by schimanke
Hi!

I hope somebody can help me with a question regarding an expression within the Regexp Plugin. I need to replace a string like
\ud83d\ude0a\ud83d\ude0a\ud83d\ude0a
This basically an ASCII representation of emojis which do not get interpreted. I have played around a little with the plugin and ended up with

Code: Select all

$regexpArray = array(
    'SearchArray' => array("/[^\w]\\\u([\w]+)/i"),
    'ReplaceArray' => array(' test')
); 
However, this will only replace the first occurence of \u until the next backslash appears. In the example above this would result in
test\ud83d\ude0a\ud83d\ude0a
Does anybody have an idea what expression I have to configure to replace the hole string?

Thanks in advance!

Re: Regexep Plugin

Posted: Sat Jun 04, 2016 12:24 pm
by onli
This should work:

Code: Select all

/[^\w](\\\u([\w]+))+/i
Slightly related: If you use mysql, there is currently a bug preventing emoji from being stored. We use the wrong UTF8 encoding in the database. This is the big current bug to fix for s9y 2.2, https://github.com/s9y/Serendipity/issues/394.

Re: Regexep Plugin

Posted: Sat Jun 04, 2016 1:28 pm
by schimanke
Yep, that worked!
Thank you very much. You made my day! :)

Re: Regexep Plugin

Posted: Sat Jun 18, 2016 3:26 pm
by schimanke
Okay, I recently ran into another problem. Is it possible to extend the Regexep Plugin to not only handle the text within the comments feld but also the text entered into the name field?

Re: Regexep Plugin

Posted: Mon Jun 20, 2016 11:25 am
by onli
What is your use case exactly?

The easiest way would be to do this in your theme. In the commentform template, you can use the html55 feature of input patterns to show your users what is allowed.