you could white list characters that you want to allow or blacklist the special character you don’t want to include.
untested code ahead
$pattern1 = '([A-Za-z0-9]+)'; //allow only letters and numbers
$pattern2 = '([^!@#\\$%\\^&\\*])'; //exclude !@#$%^&* characters
//example
if( preg_match($pattern1, $url, $matches) ){
//add to site map
}
I’m no expert on regular expressions so I’m not entire sure if the code will work but this is one good way of looking for specific characters in a string. alternatively you could use strstr($url, $char) to look for it.