- var route_rule = "{游戏标题}";
- var game_title = "闪烁之光";
- var pattern = /\{[\u4e00-\u9fa5]+\}/g;
- var matched = route_rule.match(pattern);
- console.log(matched);
- if (matched) {
- var result = route_rule.replace(pattern,game_title);
- console.log(route_rule, result);
- }
- var reg = new RegExp("{游戏标题}", "g");
- var newstr = route_rule.replace(reg, game_title);
- console.log(newstr);
-
- var input = '["\u7cbe\u54c1","\u70ed\u6e38","\u65b0\u670d"]';
- var a = JSON.parse(input);
- console.log(a)
- var b = a.toString();
- console.log(b)
运行结果
[ '{游戏标题}' ] {游戏标题} 闪烁之光 闪烁之光 [ '精品', '热游', '新服' ] 精品,热游,新服