JavaScript replace()

Posted by d3020 on Stack Overflow See other posts from Stack Overflow or by d3020
Published on 2010-03-26T14:57:48Z Indexed on 2010/03/26 15:03 UTC
Read the original article Hit count: 232

Filed under:
|

I'm trying to use the replace function in JavaScript and have a question.

strNewDdlVolCannRegion = strNewDdlVolCannRegion.replace(/_existing_0/gi, "existing" + "newCounter");

That works.

But I need to have the "0" be a variable.

I've tried: _ + myVariable +/gi and also tried _ + 'myVariable' + /gi

Could someone lend a hand with the syntax for this, please. Thank you.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about replace