stargateatlantis
asked on
Replace all characters except Numbers Letters and space
Using ereg_replace I want to replace all HTML characters the only characters i want is ALPHA Numeric and space
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
You can also try the preg_replace which is often faster than ereg_replace.
I am not sure if you need to use multiline mode. If yes, just change expression to
$pattern = '/[^a-z0-9\s]/im';
You can also try the preg_replace which is often faster than ereg_replace.
I am not sure if you need to use multiline mode. If yes, just change expression to
$pattern = '/[^a-z0-9\s]/im';
<?php
$string = 'yourHTML';
$pattern = '/[^a-z0-9\s]/i';
$replacement = '';
echo preg_replace($pattern, $replacement, $string);
?>
Open in new window