简体   繁体   English

Eclipse替换两条相同的线

[英]Eclipse To replace two same line

By mistakenly i have replace couple of line in all the java files by using global replace (CTRL + H) function. 通过错误地我已经使用全局替换(CTRL + H)函数替换了所有java文件中的几行。 as currently text is as below :- 当前文本如下:

data.creationtime = DateUtils.convertDateTimeFromServer(data.creationtime);
data.creationtime = DateUtils.convertDateTimeFromServer(data.creationtime); 

and i want to replace last line with correct word as below :- 我想用正确的单词替换最后一行,如下所示:

data.creationtime = DateUtils.convertDateTimeFromServer(data.creationtime);
data.modificationtime = DateUtils.convertDateTimeFromServer(data.modificationtime);

i am not sure how to do it because i have two identical lines , can some one please guide me ? 我不确定该怎么做,因为我有两条相同的路线,请问有人可以指导我吗?

i have followed this link but regex patterns is not working 我已遵循此链接,但正则表达式模式不起作用

SOLUTION

I have tried below pattern and it worked 我试过下面的模式,它的工作

For Match :- 匹配:-
(data.creationtime = DateUtils.convertDateTimeFromServer\\(data.creationtime\\);\\s*?data.)([^ ]+?)( = DateUtils.convertDateTimeFromServer\\(*?data.)([^ ]+?)(\\);)

For Replace :- $1modificationtime$3modificationtime$5 替换:- $1modificationtime$3modificationtime$5

Maybe not the most efficient way, but it should work. 也许不是最有效的方法,但它应该可以工作。

Search-Pattern: 搜索模式:

(data.creationtime = DateUtils.convertDateTimeFromServer\(data.creationtime\);\s*?data.)([^ ]+?)( = DateUtils.convertDateTimeFromServer\(data.creationtime\);)

Replacement-Pattern: 更换方式:

$1modificationtime$3

Demo: https://www.myregextester.com/?r=da9d3e48 演示: https //www.myregextester.com/?r = da9d3e48

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM