javascript - What is the correct pattern to the text? -


i have string follows:

var str = "visit {inside string}";  

i want replace {inside string} 'myschool'.

i tried doing below

var n = str.replace(/[{][^\s*][^\*}]/,'myschool'); 

but not working expected.

any pointer?

you can use

var n = str.replace(/\{[^}]*\}/,'myschool'); 

note if have more 1 replacement you'll have use g flag :

var n = str.replace(/\{[^}]*\}/g,'myschool'); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -