Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

6
Wiktor Stribiżew
  • 631.1k
  • 41
  • 503
  • 633
Post Closed as "Duplicate" by Wiktor Stribiżew javascript Users with the javascript badge or a synonym can single-handedly close questions as duplicates and reopen them as needed.
Post Reopened by Wiktor Stribiżew javascript Users with the javascript badge or a synonym can single-handedly close questions as duplicates and reopen them as needed.
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

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?

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?

insert duplicate link
Source Link

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 ?

Post Closed as "exact duplicate" by casperOne
regex tag
Link
PEZ
  • 17k
  • 7
  • 48
  • 66
Loading
Source Link
Nrj
  • 6.9k
  • 7
  • 49
  • 59
Loading
lang-js

AltStyle によって変換されたページ (->オリジナル) /