3
I am able to remove the non-alphanumeric ones as follows preg_replace('/[^a-z0-9\s]/i', null, $string );
However, in this way I am losing the accentuation of words, someone has some answer?
3
I am able to remove the non-alphanumeric ones as follows preg_replace('/[^a-z0-9\s]/i', null, $string );
However, in this way I am losing the accentuation of words, someone has some answer?
5
I’m not sure what you’re trying to filter but looking for digits and letters should work well:
[^\p{L}\p{N}\s]
means anything that is not:
\p{L}
- letters
\p{N}
- digits
\s
- blank space
You can use it like this:
$string = 'Olá amanhã é dia! #20%';
$limpa = preg_replace('/[^\p{L}\p{N}\s]/', '', $string );
echo $limpa;
The result is:
Olá amanhã é dia 20
Browser other questions tagged php string accentuation
You are not signed in. Login or sign up in order to post.
Reference: http://php.net/manual/en/regexp.reference.unicode.php
– bfavaretto
Help guy :) thanks a lot
– Lucas Pires
I didn’t know that P
– Bruno Augusto