Q:

Regex in javascript

Please, help me.  I have a variable lang and i know that after this variable must go characters -(.+);
For example, i would have written it in C # so - regexString = lang + "-(.+);";
But in javascript this code not correct: str1 = str1.replace(lang+"-(.+);", replacement); because there must use /.../, but i don't know how to write correct

A:

There is a dynamic way to create regexps in javascript:
new RegExp(lang+'\-(.+)')

(I also escaped the -.) 
So to do a replace:
str.replace(new Regexp(lang+'\-(.+)'), replacement)

If you want to replace more than 1:
str.replace(new Regexp(lang+'\-(.+)', 'g'), replacement)

The 'g' flag is for 'global'.