比如
<if test="id != null ">
<if test="merOrderId != null ">
<if test="bankOrderId != null ">
<if test="merId != null ">
<if test="siteId != null ">
要替换成
<if test="id != null and id ! = '' ">
<if test="merOrderId != null and merOrderId ! = ''">
<if test="bankOrderId != null and bankOrderId ! = ''">
<if test="merId != null and merId ! = ''">
<if test="siteId != null and siteId ! = ''">
查找是 查找 <if test=".* != null "> 可以找出所有
但是要替换成什么内容,要怎么写
用
(?<=(test="))(.+)(?=!=)
匹配到 id merOrderId bankOrderId
然后把结果存成变量.替换成 result != '' and result 就可以了
正则表达式描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串、将匹配的子串替换或者从某个串中取出符合某个条件的子串等.
执行替换还是要写程序的.
(?<)\d+(?=)
(?<=(test="))(.+)(?=!=)
这个可以的