搜尋

首頁  >  問答  >  主體

javascript如何使用replace替換?

雷雷
巴扎黑巴扎黑2854 天前432

全部回覆(1)我來回復

  • 天蓬老师

    天蓬老师2017-05-19 10:37:44

    不要匹配開始^和匹配末尾$

    function replacer(word) {
        return 'hello';
    }
    var newString = 'abc[你好]de[他]fg'.replace(/\[[^\u0000-\u00FF]{1,2}\]/gi, replacer);

    回覆
    0
  • 取消回覆