J.R. wrote on 22 feb 2012 in comp.lang.javascript:
> On 22/02/2012 15:48, Archos wrote:
>> How to replace all strings at the same time?
>>
>>>>> var a = "a,b,c,d";
>>>>> a.toString().replace(",", "")
>> "ab,c,d"
>
> If I understood correctly, you want to replace all the commas in a
> variable with '', right? Then you might use a RegExp such as:
>
> var a = "a,b,c,d";
> a.replace(/,/g, '')
>
var a = "a,b,c,d";
a = a.replace(/,/g, '');
==============
If you don't feel comfortable with Regex, try:
var a = "a,b,c,d";
a = a.split(',').join('');
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
|