JS在如何指定位置插入字符最好的英文正则
展开全部
var str = "NN:CNY200/CNY100/CNY50/\r\nMM:USD200/USD100/USD50/\r\n欧元300EUR 费率3.8% 收益0.1%";
var reg = /(([^\/]+\/){2})([^\/]+\/?)([\r\n\f\t\s\x20]*([^\/]+\/){2})([^\/]+\/?)[\r\n\f\t\s\x20]*\D+([^\s]+)\D+([^\s]+)\D+([^\s]+)/g;
str = str.replace(reg,"$1$7/$3$4$8/$6$9");
console.log(str);
var reg = /(([^\/]+\/){2})([^\/]+\/?)([\r\n\f\t\s\x20]*([^\/]+\/){2})([^\/]+\/?)[\r\n\f\t\s\x20]*\D+([^\s]+)\D+([^\s]+)\D+([^\s]+)/g;
str = str.replace(reg,"$1$7/$3$4$8/$6$9");
console.log(str);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询