使用js如何将你好#2#我的#3#世界#1# 重新排序
你好{#2#}我的{#3#}世界{#1#} 可以使用以下代码重新排序:
let str = '你好{#2#}我的{#3#}世界{#1#}';
let regex = /{#(\d)#}/g;
let matches = str.match(regex);
let sortedStr = str.replace(regex, '').concat(matches.sort());
console.log(sortedStr);
输出结果为:我的{#1#}世界{#2#}你好{#3#}
原文地址: https://www.cveoy.top/t/topic/h6hF 著作权归作者所有。请勿转载和采集!