- 631.1k
- 41
- 503
- 633
Possible Duplicate:
Escape string for use in Javascript regex Escape string for use in Javascript regex
I have a msg like this:
Max {0} chars allowed in {1}
And I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that it's not able to take the param i to create the reg exp.
What's the way to achieve this?
Possible Duplicate:
Escape string for use in Javascript regex
I have a msg like this:
Max {0} chars allowed in {1}
And I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that it's not able to take the param i to create the reg exp.
What's the way to achieve this?
Possible Duplicate:
Escape string for use in Javascript regex
I have a msg like this:
Max {0} chars allowed in {1}
And I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that it's not able to take the param i to create the reg exp.
What's the way to achieve this?
- 6.8k
- 2
- 46
- 63
Possible Duplicate:
Escape string for use in Javascript regex
I have a msg like this:
Max {0} chars allowed in {1}
And I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
}
The problem is that itsit's not able to take the param "i" toi to create the reg exp.
WhatsWhat's the way to achieve the same this?
Possible Duplicate:
Escape string for use in Javascript regex
I have a msg like
Max {0} chars allowed in {1}
I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that its not able to take the param "i" to create the reg exp.
Whats the way to achieve the same ?
Possible Duplicate:
Escape string for use in Javascript regex
I have a msg like this:
Max {0} chars allowed in {1}
And I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that it's not able to take the param i to create the reg exp.
What's the way to achieve this?
Possible Duplicate:
Escape string for use in Javascript regex
I have a msg like
Max {0} chars allowed in {1}
I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that its not able to take the param "i" to create the reg exp.
Whats the way to achieve the same ?
I have a msg like
Max {0} chars allowed in {1}
I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that its not able to take the param "i" to create the reg exp.
Whats the way to achieve the same ?
Possible Duplicate:
Escape string for use in Javascript regex
I have a msg like
Max {0} chars allowed in {1}
I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that its not able to take the param "i" to create the reg exp.
Whats the way to achieve the same ?