Home > Back-end >  Preg Replace a curly apostrophe?
Preg Replace a curly apostrophe?

Time:08-25

I'm trying to use preg replace to replace a single curly postrophe (amongst other characters but I have excluded them from my example).

preg_replace('/[‘]/', 'x', '‘');

Unfortunately the above outputs xxx, I would expect to only see a single x. Where am I going wrong?

CodePudding user response:

Make it unicode capable by adding the u flag.

echo preg_replace("/[‘]/u", 'x', '‘');

prints

x
  •  Tags:  
  • php
  • Related