I'm able to remove the non-alphanumeric as follows preg_replace('/[^a-z0-9\s]/i', null, $string );
But in this way I'm losing the accentuation of words, does anyone have an answer?
I'm able to remove the non-alphanumeric as follows preg_replace('/[^a-z0-9\s]/i', null, $string );
But in this way I'm losing the accentuation of words, does anyone have an answer?
I'm not sure what you're trying to filter but looking for digits and letters should work fine:
[^\p{L}\p{N}\s]
means everything that is not:
\p{L}
- letters
\p{N}
- digits
\s
- blank space
You can use this:
$string = 'Olá amanhã é dia! #20%';
$limpa = preg_replace('/[^\p{L}\p{N}\s]/', '', $string );
echo $limpa;
The result is:
Olá amanhã é dia 20