如何在 Eclipse 中搜索和替换 2 行(一起)? [英] How to search and replace 2 lines (together) in Eclipse?
本文介绍了如何在 Eclipse 中搜索和替换 2 行(一起)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过 eclipse 在多个文件中搜索以下 2 行:
@Length(max = L_255)私人字符串描述;
并用这两个替换它们:
@Length(max = L_255, message="{validator.description.len}")私人字符串描述;
解决方案
当您使用正则表达式时,Eclipse 中默认搜索是多行的:
(@Length(max = L_255))([
s]+private)
<块引用>
我想添加私有字符串描述;"
(@Length(max = L_255))([
s]+privates+?Strings+descriptions*?;)
替换为:
1, message="{validator.description.len}")2
它在由 CTRL-H 触发的文件搜索中完美运行.
如 Tika 的 回答,您可以直接复制在包含文本"字段中选择的两行:这些行将被转换为正则表达式日食.
I would like to search multiple files via eclipse for the following 2 lines:
@Length(max = L_255)
private String description;
and replace them with these two:
@Length(max = L_255, message="{validator.description.len}")
private String description;
解决方案
Search are multi-line by default in Eclipse when you are using regex:
(@Length(max = L_255))([
s]+private)
I would like to add "private String description;"
(@Length(max = L_255))([
s]+privates+?Strings+descriptions*?;)
replaced by:
1, message="{validator.description.len}")2
It works perfectly in a File Search triggered by a CTRL-H.
As mentioned in Tika's answer, you can directly copy the two lines selected in the "Containing Text" field: those lines will be converted as a regexp for you by Eclipse.
这篇关于如何在 Eclipse 中搜索和替换 2 行(一起)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文