phpregexphp-5.3

How to match horizontal ellipse (…) in php


I want to replace the horizontal ellipse (…) with three period (...)in a given string.
Till now I have tried are:

str_replace('…','...', $text);
str_replace('…', '...', $text);
str_replace('&hellips', '...', $text);

But not able to get the desired output. Can you please suggest some method for it.

EDIT:
One more problem I am facing related to this is when I paste the ~…~u character in my editor (I am using Editplus). the ... are converted into a rectangle. (see screenshot). enter image description here

Thanks


Solution

  • try to use preg_replace with the /u modifier (the string is treated as an unicode string):

    $result = preg_replace('~…~u', '...', $string);