views:

40

answers:

3
+1  Q: 

javascript replace

hello, i want to replace month name by number in array, but my script doesnt work.

for(i=0; i<a.length; i++) {
arr = arr.replace(/Jan/g, "01");
}

Can somebody help me please?

+6  A: 

Perhaps you need:

arr[i] = arr[i].replace(/Jan/g, "01");
kgiannakakis
yes, i try this too, but without success
+1  A: 

Try this:

for(i=0; i<a.length; i++) { 
    arr[i] = arr[i].replace(/Jan/gi, "01"); 
} 

Also... Shouldn't the line be:

for(i=0; i < arr.length; i++) {
zinc
thanks, now it works
Also note../Jan/gi Not /Jan/g
zinc
A: 
for(i=0; i<a.length; i++) {
  a[i] = a[i].replace(/Jan/g, "01");
}
fire