views:

13

answers:

2

Is there an easy way to do the equivalent in jquery or jscript for that matter.

NewString = Regex.Replace(SOMESTRING, "[^a-z0-9A-Z -]") 
A: 

Like this:

newString = someString.replace(/[^a-z0-9A-Z -]/g, "");

Without the g (Global) flag,it will only replace the first match.

SLaks
A: 
NewString = SOMESTRING.replace(/[^a-z0-9A-Z -]/g, "new string")

But what you wrote isn't actually a valid static method of Regex.

Yuriy Faktorovich
**You need to assign the return value** – Strings are immutable.
SLaks
@SLaks: I'm not that dumb, just didn't translate the entire line, edited. Although I did steal the /g from you, thanks.
Yuriy Faktorovich
Yes; you and I realize that. However, Joe Programmer might not.
SLaks