Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1583 How can I replace all non alphanumeric characters from a string?

You are here: irt.org | FAQ | JavaScript | Text | Q1583 [ previous next ]

Use a regular expression:

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

©2018 Martin Webb