You can use a regular expression to remove everything but alphanumeric and punctuation characters. $string =~ s/[^[:alnum:]^[:punct:]]+//; Code (markup): I have not verified this regex works, but you can use a site like http://regex.powertoy.org/ to verify it before you use it.
Thanks, but I managed to find a regex that worked. There were people having the same problem as me and they used a regex to wipe out alphanumerics > 127, which is all special text characters: $test_string =~ s/(.)/(ord($1) > 127) ? "" : $1/egs; Code (markup): BEFORE: AFTER: If I run into more bugs with the code I'll try what you suggested to see if it helps.