Get text between two rounded brackets

后端 未结 5 1529
小蘑菇
小蘑菇 2020-11-29 08:19

How can I retrieve the word my from between the two rounded brackets in the following sentence using a regex in JavaScript?

\"This is (my

5条回答
  •  情书的邮戳
    2020-11-29 08:23

    var txt = "This is (my) simple text";
    re = /\((.*)\)/;
    console.log(txt.match(re)[1]);​
    

    jsFiddle example

提交回复
热议问题