Replace all unwanted characters with a regular expression - how?Greetings,<br><br>I need to replace all characters in a string that are not numeric or alpha.  I've got a test string that is <font color="#a31515" size=2>&quot;Nissay Dowa General-Happy&quot;</font>.  I need to change the string so that it becomes <font color="#a31515" size=2>&quot;NissayDowaGeneralHappy&quot;.  </font>The JavaScript that I have created removes only the first space, resulting in <font color="#a31515" size=2>&quot;NissayDowa General-Happy&quot;</font>.  The regular expression I am using is shown below.  Can someone tell me how to do it the right way, removing all spaces and the dash character?<br><br><font size=2> <p>mystring = </font><font color="#a31515" size=2>&quot;Nissay Dowa General-Happy&quot;</font><font size=2>;</p> <p>regexp = /[^A-Za-z0-9]/;</p> <p>newstring = mystring.replace(regexp, </font><font color="#a31515" size=2>&quot;&quot;</font><font size=2>);</p> <p>alert(newstring);<br><br>Gracias!</p></font>© 2009 Microsoft Corporation. All rights reserved.Thu, 09 Oct 2008 20:07:23 Z422926d1-94ed-4be5-ba15-59746ec24fd0http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/422926d1-94ed-4be5-ba15-59746ec24fd0#422926d1-94ed-4be5-ba15-59746ec24fd0http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/422926d1-94ed-4be5-ba15-59746ec24fd0#422926d1-94ed-4be5-ba15-59746ec24fd0BlackCatBonehttp://social.msdn.microsoft.com/Profile/en-US/?user=BlackCatBoneReplace all unwanted characters with a regular expression - how?Greetings,<br><br>I need to replace all characters in a string that are not numeric or alpha.  I've got a test string that is <font color="#a31515" size=2>&quot;Nissay Dowa General-Happy&quot;</font>.  I need to change the string so that it becomes <font color="#a31515" size=2>&quot;NissayDowaGeneralHappy&quot;.  </font>The JavaScript that I have created removes only the first space, resulting in <font color="#a31515" size=2>&quot;NissayDowa General-Happy&quot;</font>.  The regular expression I am using is shown below.  Can someone tell me how to do it the right way, removing all spaces and the dash character?<br><br><font size=2> <p>mystring = </font><font color="#a31515" size=2>&quot;Nissay Dowa General-Happy&quot;</font><font size=2>;</p> <p>regexp = /[^A-Za-z0-9]/;</p> <p>newstring = mystring.replace(regexp, </font><font color="#a31515" size=2>&quot;&quot;</font><font size=2>);</p> <p>alert(newstring);<br><br>Gracias!</p></font>Wed, 09 Jul 2008 21:10:57 Z2008-07-09T21:10:57Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/422926d1-94ed-4be5-ba15-59746ec24fd0#149bc1a0-035f-427d-82ed-7d02f85c1d6bhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/422926d1-94ed-4be5-ba15-59746ec24fd0#149bc1a0-035f-427d-82ed-7d02f85c1d6brtizan[0]http://social.msdn.microsoft.com/Profile/en-US/?user=rtizan%5b0%5dReplace all unwanted characters with a regular expression - how?Hi,<br><br><font size=2>regexp = /[^A-Za-z0-9]/g;</font><br><br>should do it.<br><br>Good luck,<br><br>John<br> Thu, 10 Jul 2008 00:31:40 Z2008-07-10T00:31:40Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/422926d1-94ed-4be5-ba15-59746ec24fd0#7c9ffabc-1271-46e1-920d-60679d67eee3http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/422926d1-94ed-4be5-ba15-59746ec24fd0#7c9ffabc-1271-46e1-920d-60679d67eee3Toronto Danhttp://social.msdn.microsoft.com/Profile/en-US/?user=Toronto%20DanReplace all unwanted characters with a regular expression - how? You may want to try \D \W (not digit, not character), include \S if you want &quot;not white space&quot;Thu, 10 Jul 2008 15:23:58 Z2008-07-10T15:23:58Z