[thelist] regexp replace?
Hassan Schroeder
hassan at webtuitive.com
Wed Jun 19 18:47:01 CDT 2002
Tom Dell'Aringa wrote:
>
> Sorry, in JavaScript!
>
> so "s/-//g" is the match right? is that saying find "-" globally? Then how can I replace it?
JavaScript also has a replace() function, but it takes a regexp as
an argument (unlike Java), so --
newSSNString = originalSSNString.replace(/-/g, "");
The sed-style 's/-//g' also replaces the - with "", because there's
no replacement text in the second pairing of slashes // , and yes,
the 'g' means global.
--
H*
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
-- creating dynamic Web sites and applications since 1994 --
More information about the thelist
mailing list