JS regex replace not working

前端 未结 1 597
花落未央
花落未央 2020-12-21 04:31

I\'ve got a JS string

var str = \'@robot ping\'; 

I need to remove this part of a string

         


        
相关标签:
1条回答
  • 2020-12-21 05:12

    Use // for regex. Replace "<at.+@" with /<at.+@/.

    var str = '<at id="11:12345678">@robot</at> ping'; 
    
    str = str.replace(/<at.+@/,"");
    
    console.log(str);

    Documentation for replace

    0 讨论(0)
提交回复
热议问题