469,626 Members | 833 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Global, Case-Insensitive replace()

hsriat
1,654 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. function repAll(t) {
  2.   var finds = new Array(......); //array of to-be-replaced strings
  3.   var repls = new Array(......); //array of replace-with strings
  4.   t = t.replace(finds[i], repls[i], 'gi');
  5. }
Working fine with FF, but not with IE, Opera and Safari...

How can I solve this?
Feb 20 '08 #1
4 2302
hsriat
1,654 Expert 1GB
Missed one line in the previous post.

Expand|Select|Wrap|Line Numbers
  1. function repAll(t) {
  2.   var finds = new Array(......); //array of to-be-replaced strings
  3.   var repls = new Array(......); //array of corresponding replace-with strings
  4.   for (var i=0; i<finds.length; i++)
  5.   t = t.replace(finds[i], repls[i], 'gi');
  6. }
Feb 21 '08 #2
acoder
16,027 Expert Mod 8TB
See this example.
Feb 21 '08 #3
hsriat
1,654 Expert 1GB
See this example.
I saw that already, but the difference is, they are using string itself, while I'm using reference. How could I add /gi to a referance?
Feb 21 '08 #4
acoder
16,027 Expert Mod 8TB
Use the RegExp object, e.g. see this link.
Feb 21 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Stan Sainte-Rose | last post: by
2 posts views Thread by Gianguz | last post: by
11 posts views Thread by Capstar | last post: by
8 posts views Thread by Thomas Coleman | last post: by
10 posts views Thread by m.epper | last post: by
44 posts views Thread by fabio | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.