regex between two special characters

后端 未结 6 1243
花落未央
花落未央 2021-01-26 11:12

Is there a way to replicate this PHP snippet in JQuery or Javascript...



        
6条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-26 11:33

    var str = '{Some groovy text}not so groovy text';
    var regex = /\{(.*?)\}/;
    var value = str.match(regex)[1];  // 'Some groovy text';
    

    This will retrieve the content within the brackets. Hope this helps.

提交回复
热议问题