1

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?

asked Feb 12, 2010 at 11:09
0

3 Answers 3

6

Perhaps you need:

arr[i] = arr[i].replace(/Jan/g, "01");
Amber
532k89 gold badges643 silver badges558 bronze badges
answered Feb 12, 2010 at 11:11
Sign up to request clarification or add additional context in comments.

Comments

1

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++) {
answered Feb 12, 2010 at 11:12

1 Comment

Also note.. /Jan/gi Not /Jan/g
0
for(i=0; i<a.length; i++) {
 a[i] = a[i].replace(/Jan/g, "01");
}
answered Feb 12, 2010 at 11:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.