Revision: 38145
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 27, 2010 02:24 by daipratt
Initial Code
//Remove from a single line string
$output = "Likening ‘not-critical’ with";
$output = preg_replace('/[^(\x20-\x7F)]*/','', $output);
echo $output;
//Remove from a multi-line string
$output = "Likening ‘not-critical’ with \n Likening ‘not-critical’ with \r Likening ‘not-critical’ with. ' ! -.";
$output = preg_replace('/[^(\x20-\x7F)\x0A\x0D]*/','', $output);
echo $output;
Initial URL
http://daipratt.co.uk/
Initial Description
This will remove all non-ascii characters / special characters from a string.
Initial Title
PHP regex - Remove special characters from a string
Initial Tags
php
Initial Language
PHP