A minor inconvenience my users have found is that if they use a smilie such as >_>
at the end of parentheses (kind of like this: >_>) then during processing it is run through htmlspecialchars()
, making it >_>)
- you can see the problem, I think. The ;)
at the end is then replaced by the "Wink" smilie.
Can anyone give me a regex that will replace ;)
with the smilie, but only if the ;
is not the end of an HTML entity? (I'm sure it would involve a lookbehind but I can't seem to understand how to use them >_>)
Thank you!
Handling smileys like ;)
is always a bit tricky - the way I would do it is transform it to the "canonical" :wink:
before encoding HTML entities, and then changing only canonical-form :{smileyname}:
smileys afterwards.
Like this: (?<!&[a-zA-Z0-9]+);\)
The (?>!...)
is a zero-width assertion that will only allow the following construct to match text that isn't preceded by the ...
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With