I use the following function to clean-up my string before I use it on my export:
function cleanString($source) {
$source = str_replace('&', 'and', $source);
$source = preg_replace('~[^\p{L}\p{N}]++~u', ' ', $source);
return trim($source);
}
This works fine, but I want to modify it to allow , (commas) and parenthesis ( and ).
At the moment, this is what's happening:
Name, Brand Name (Some & Slogan) ==> Name Brand Name Some and Slogan
How can I update the above regex pattern to allow commas and parenthesis?
I tried the following: $source = preg_replace('~[^\p{L}\p{N}]++~u\,\(\)', ' ', $source); and I am getting the error: Unknown modifier '\'.
Any ideas?