Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.