Skip to content

Instantly share code, notes, and snippets.

@krisclarkdev
Created January 7, 2019 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisclarkdev/0882b3e84b7e2f573483dac12391e91d to your computer and use it in GitHub Desktop.
Save krisclarkdev/0882b3e84b7e2f573483dac12391e91d to your computer and use it in GitHub Desktop.
Replace special characters with underscores
$(document).ready(function() {
var testString = '\'"some!@#456":<>?/`~=+String';
$('#before').html(testString);
$('#after').html(testString.replace(/[^a-zA-Z0-9]/g,'_'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment