Last updated on August 30th, 2022 at 06:52 pm

In this tutorial we will discuss on how to replace non alphanumeric characters using JavaScript

<script language="JavaScript">
var temp = new String('This is a te!!!!st st>ring... So??? What...');
document.write('<b>Original String:-</b>'+temp + '<br />');
temp =  temp.replace(/[^a-zA-Z 0-9 ]+/g,'');
document.write('<b>Replaced String:- </b>'+temp + '<br />');

Just insert the above code within <body> tag and see the magic.

Demo

Leave a Reply

Your email address will not be published. Required fields are marked *