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}

```


#### 截图:

![image.png](https://upload-images.jianshu.io/upload_images/12858151-8e10d1dc0b0ba281.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


评论
© Saxon | Powered by LOFTER
下一篇