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

2020-08-19  本文已影响0人  Saxon_323e

原始内容:

    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}

截图:

image.png
上一篇下一篇

猜你喜欢

热点阅读