How to use 'remove all non-alphanumeric characters javascript' in JavaScript

Every line of 'remove all non-alphanumeric characters javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
1export function cleanAlphaNumericString(str: string): string {
2 return (str && typeof str === "string") ? str.replace(/\W/g, '') : str;
21function allowalphanumeric(e) {
22 var key = window.event ? e.keyCode : e.which;
23 var keychar = String.fromCharCode(key);
24 var reg = new RegExp("[a-zA-Z0-9]");
25 var carok = reg.test(keychar);
26 return carok;

Related snippets