Reputation: 372
I want to use preg_replace
to clean a string but I want to contine with this character () - Parentheses
I'm using this code
$string = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $string);
$string = preg_replace('/[^\p{Latin}\d ]/u', '', $string);
I want to remove everything except the parentheses letters and numbers
Upvotes: 0
Views: 342
Reputation:
If I understand you correctly, use:
/[^\p{Latin}0-9()]/u
That will match anything that is not parentheses, letters or numbers.
So the full code:
$string = preg_replace('/[^\p{Latin}0-9()]/u', '', $string);
Upvotes: 2