javascript - 有正则高手吗? 帮忙解决一下这个问题
本文介绍了javascript - 有正则高手吗? 帮忙解决一下这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
现在有一条sql语句
select ID as id,Name as name,IP as ip,lat,lon,0 as type from trk.devs_v2 where type=0 union all select id,signalName as name,ip,lat,lng as lon,99 as type from yc_signal.signal union all
想使用正则让最后一个union all去掉 而不是去掉所有的union all
想要的结果为
select ID as id,Name as name,IP as ip,lat,lon,0 as type from trk.devs_v2 where type=0 union all select id,signalName as name,ip,lat,lng as lon,99 as type from yc_signal.signal
有正则大神帮帮忙呗! 万分感谢
解决方案
let str = "union albdfdfdfunion alaadunion al";
let reg = str.replace(/(union al)$/,'');
console.log(reg)
这篇关于javascript - 有正则高手吗? 帮忙解决一下这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文