borje wrote:
when i enter for example xy~abc123 (tilde) in the input box, the ~ (tilde) will echo with the example above.. but if i run $string = ereg_replace('[0-9a-z]','',$string); it will not. apprently ~ (tilde) is not included in the (longer)string far up, but why does it echo.
am i missing a point here?
No, actually you fond a bug with POSIX extensions in PHP posix-extended regex.
Appearantly, <> matches ˜
That is not good.
But, fine for me, because I always though ereg sucked ass anyway.
I always use preg.
Before it was just because it was substantially faster executing.
But now, it will be because it's got less bugs too.
<?
$string = 'xy~abc123';
$string = preg_replace('/[0-9a-zA-Z!#\$%&.\?*,[]\'\"+-<=^>()]+/','',$string);
echo $string;
?>