Reputation: 538
I'm trying to remove special chars by allowing only the patter bellow.
'/[^A-Za-z0-9ÀÁÉÍÓÚÇÃÕÂÊÔàáéíóúçãõâêô\~!@#\$\%\^\&*()-_\=+\|{}[]\;:\'\"\<>\,./\?\s\n]/'
But when I run my script, it returns all characters not allowed © ® ñ ö
mb_regex_encoding('UTF-8');
$string = 'teste © ® ñ ö ';
echo mb_ereg_replace('/[^A-Za-z0-9ÀÁÉÍÓÚÇÃÕÂÊÔàáéíóúçãõâêô\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\|\{\}\[\]\;\:\'\"\<\>\,\.\/\?\s\n]/', '', $string);
Return:
teste © ® é ñ ö
Upvotes: 1
Views: 329
Reputation: 4967
<?php
mb_regex_encoding('utf-8');
$pattern = "[^A-Za-z0-9ÀÁÉÍÓÚÇÃÕÂÊÔàáéíóúçãõâêô~!@#$%^&*()-_=+|{}\[\];:'\"<>,.\/\?\s\n]+";
$in = "teste © ® ñ ö";
echo mb_ereg_replace($pattern,"", $in);
There is a difference in how you setup the pattern in ereg vs preg
Upvotes: 4