如何在Eclipse中一起搜索和替换2行? [英] How to search and replace 2 lines (together) in Eclipse?

查看:85
本文介绍了如何在Eclipse中一起搜索和替换2行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过Eclipse搜索以下两行的多个文件:

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;


推荐答案

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆