replace special characters in string, ruby code example Example: ruby remove unsafe file characters str.gsub(/[^0-9A-Za-z]/, '')