天天看点

NotePad++或其他编辑器正则批量替换实例

原始内容:

public ScmClientBuilder withCommType(ConfCommType commType) {
        this.commType = commType;
        return this;
    }

    public ScmClientBuilder withListeners(ScmEventListener... listeners) {
        this.listeners = listeners;
        return this;
    }           

目标内容:

public ScmClientBuilder withCommType(ConfCommType commType) {
        if (nonNull(commType)) {
             this.commType = commType;   
        }
        return this;
    }

    public ScmClientBuilder withListeners(ScmEventListener... listeners) {
        if (nonNull(listeners)) {
             this.listeners = listeners;   
        }
        return this;
    }           

查找正则:

this.([0-9a-zA-Z]+) = ([0-9a-zA-Z]+);           

替换正则:

if \(nonNull\($1\)\) {\n  this.$1=$1;   \n}           

截图:

继续阅读