|
Q1583 How can I replace all non alphanumeric characters from a string?
irt.org | Knowledge Base | JavaScript | Text | Q1583 [ previous next ]
Q1583 How can I replace all non alphanumeric characters from a string?
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>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.