PHP Replace EM Dash REGEX -
i trying replace character http://www.fileformat.info/info/unicode/char/2014/index.htm regular dash , have yet cant seem work?
$dataold = "9am – 5pm"; // ms word doc $data = mb_ereg_replace("[\xe2 \x80 \x94]", " - ", $dataold); print_r($data);
why bother octal unicode format? why not...
replace n-dash
$dataold = "9am – 5pm"; // ms word doc $data = mb_ereg_replace(" – ", " - ", $dataold); print_r($data);
replace m-dash
$dataold = "9am — 5pm"; // ms word doc $data = mb_ereg_replace(" — ", " - ", $dataold); print_r($data);
your original code works fine, except sample text string has n-dash , you're testing m-dash. (and have spaces in regex). try this...
$dataold = "9am — 5pm"; // ms word doc $data = mb_ereg_replace("[\xe2\x80\x94]", " - ", $dataold); print_r($data);
Comments
Post a Comment