-
-
Save jgraffin/0ea14c40003caff2697efabc16f55bf5 to your computer and use it in GitHub Desktop.
JS Function to remove dashes. You can use it for other characters as well by changing the js regular expression.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$.cleanString = function(testString) { | |
var numericString = testString.replace(/-/gi," "); | |
// .replace() uses regular expression. In this case, its replaceing '-' with ' '. | |
return numericString; | |
} | |
var question = "Sample-text-with-some-dashes"; | |
var cleaned = $.cleanString(question); | |
alert(cleaned); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment