I use these lines of code to remove all punctuation marks, symbols, etc as you can see them in the array,
$pattern_page = array(\"+\",\",\",\".\",\"-\",\"\'\
Use classes:
preg_replace('/[^[:alpha:]]/', '', $input);
Would remove anything that's not considered a "character" by the currently set locale. If it's punctuation, you seek to eliminate, the class would be [:punct:]
.
\W
means "any non-word character" and is the opposite of \w
which includes underscores (_
).
Depending on how greedy you'd like to be, you could do something like:
$pg_url = preg_replace("/[^a-zA-Z 0-9]+/", " ", $pg_url);
This will replace anything that isn't a letter, number or space.