如何通过eclipse搜索和替换2行(一起)? [英] How can one search and replace 2 lines (together) via eclipse?
本文介绍了如何通过eclipse搜索和替换2行(一起)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过eclipse搜索以下两行的多个文件:
I would like to search multiple files via eclipse for the following 2 lines:
@Length(max = L_255)
private String description;
并将其替换为这两个:
@Length(max = L_255, message="{validator.description.len}")
private String description;
推荐答案
在Eclipse中,默认情况下,搜索是多行的正在使用正则表达式:
Search are multi-line by default in Eclipse when you are using regex:
(\@Length\(max = L_255)\)([\r\n\s]+private)
我想添加私人字符串描述;
I would like to add "private String description;"
(\@Length\(max = L_255)\)([\r\n\s]+private\s+?String\s+description\s*?;)
替换为:
\1, message="{validator.description.len}")\2
它在由 CTRL - H 。
如 Tika 的 answer ,您可以直接复制在包含文本字段中选择的两行::这些行将被转换为正则表达式 Eclipse。
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屋!
查看全文