I'm currently using this to remove unwanted characters:
$pattern = "[^a-zA-Z0-9_ .]*";
$form_lookup = @ereg_replace($pattern, '', $form_lookup);
How can I include/allow the @ sign?
These seem not to work as expected:
$pattern = "[^a-zA-Z0-9_ .\@]*";
$pattern = "[^a-zA-Z0-9_ .@]*";
Instead of ereg_replace
use preg_replace
:
$form_lookup = 'foo@!:_;';
$pattern = '/[^a-zA-Z0-9_ .@]*/';
$form_lookup = preg_replace($pattern, '', $form_lookup);
Output:
string 'foo@_' (length=5)
You can use this regex:
/[^\w\s@-.]/
And use preg_*
and not ereg_*
asi it is deprecated