Skip to content

Instantly share code, notes, and snippets.

@alili
Created May 27, 2016 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alili/b42c55f08fd771241346664febd1e809 to your computer and use it in GitHub Desktop.
Save alili/b42c55f08fd771241346664febd1e809 to your computer and use it in GitHub Desktop.
function clearString(s){
var pattern = /[`~!@#$^&*()=|{}':;',\\[\\].<>\?~!@#¥……&*()&;|{}【】‘;:”“'。,、?]|\s/;
var rs = "";
for (var i = 0; i < s.length; i++) {
rs = rs+s.substr(i, 1).replace(pattern, '');
}
return rs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment