Eclipse 正则表达式 查找与替换
CTRL + space in the textboxes gives you all kinds of suggestions for regular expression writing.

查找


替换

Be sure to check out the \C regular expression operator, which I think is specific to Eclipse.
It saves a lot of work in replacing the same word in upper-case, lower-case, and camelCase variants.
For example, if the original text is:
SomeObject someObject = SOMEOBJECT;
then doing a "Replace All" replacing
someObject
with
\CanotherObject
will get you:
AnotherObject anotherObject = ANOTHEROBJECT;
https://dzone.com/articles/using-regular-expressions
I had an old method with hundreds of lines doing calling a getAttribute("X") and casting the result to a string.
(String)object1.getAttribute("X")
(String)object2.getAttribute("Y")
(String)objectN.getAttribute("Z")
I had to change them all to use a new method that checks if the attribute is null. So the new line would be
getSafeStringAttribute(object1,"X")
getSafeStringAttribute(object2,"Y")
getSafeStringAttribute(objectN,"Z")
With this simple regEx you can do a replace all!
find :
\(String\)(.+)\.getAttribute\("(.+)"\)
The first (.+) will match the objectX part while the second will match the attribute name.
The best thing is that when you select some text and
type CTRL + F (if the Regular Expressions checkbox is ticked)
you string in the find will be already escaped from characters like '(', ')' etc!

Eclipse 正则表达式 查找与替换的更多相关文章
- 在VS中用正则表达式查找或替换
2005VS和2008VS正则替换规则如下(2013VS不适合,不需要的同学可以直接跳到2013VS的操作办法): Example: 查找#incldue中带有gl开头的头文件的,用include.+ ...
- Java基础之一组有用的类——使用正则表达式查找和替换(SearchAndReplace)
控制台程序. 使用正则表达式执行查找和替换操作,只需要调用Matcher对象的find()方法,就可以调用appendReplacement()方法来替换匹配的子序列.在提供给方法的新StringBu ...
- VisualStudio2010正则表达式查找和替换
把 TRACE(_T("something etc."); 替换为 TRACE(_T("something etc."));查找内容:表达式:TRACE\(_T ...
- UE正则表达式查找和替换(将【,;】)替换为换行
- 在UltraEdit的查找和替换中使用正则表达式 (转)
很多朋友都用过或者正在用UltraEdit,这个编辑器陪伴我也好几年了,从很多地方影响着我写代码的快捷键习惯,Ultraedit提供了非常丰富的编辑功能,其中非常重要的查找和替换功能一定大家都用过,U ...
- VIM正则表达式查找替换
0. 一些需要注意的不同 VIM中的正则表达式和其他的有点不一样 (1) 有些符号要用\转义,比如\+表示重复一次或以上,其他的还有一些,:h pattern查看(2) 非贪婪匹配用\{-}, 如 ...
- xcode中使用正则表达式来搜索替换代码
有这样的需求: 类似于 GLOBAL_STR(@"请继续添加"); 这样的代码,需要批量修改为: GLOBAL_STR(@"请继续添加", nil); 这里使用 ...
- linux shell 字符串操作(长度,查找,替换)详解
linux shell 字符串操作(长度,查找,替换)详解 在做shell批处理程序时候,经常会涉及到字符串相关操作.有很多命令语句,如:awk,sed都可以做字符串各种操作. 其实shell内置一系 ...
- visual studio 使用正则查找或替换示例
visual studio 使用正则查找或替换示例 注意哟:使用之前应做好备份 visual studio 2015: 多行替换 (.*)point\ =(.*);\r\n.+this.([A-Za- ...
随机推荐
- 第7月第26天 iOS httpserver
1. cocoahttpserver 1)httpserver [httpServer start:&error] 2)HTTPConnection [newConnection start] ...
- ubuntu16.04系统搜狗输入法的安装
参考博客:https://www.cnblogs.com/lrj567/p/6307329.html 本来不想写的,但是最近老是重装系统,每次百度特别浪费时间,特此记录一下 先去官网下载搜狗输入法li ...
- ASP.NET MVC3 Model的常用验证示例
1.金额(10位整数,2位小数) #region 余额 /// <summary> /// 余额 /// </summary> [DisplayName("余额&qu ...
- SpringMvc定时器任务
在最近的工作中,涉及到一个定时任务,由于以前对springMVC使用较少,所以,上网找了一点资料.这个demo感觉挺好,推荐给大家. 使用到的JAR文件: aopalliance-1.0.jarcom ...
- private,protected,public和default的区别
private,protected,public和default的区别 private,protected,public和default作为Java中的访问修饰符,他们的最大区别就在于访问权限不同: ...
- Python学习笔记:算法的重要性
今日看了一个基础的教程<8分钟学会一个算法>,偶然间看到一个很简单的例子,仅当记录一下. 题目:已知a+b+c=1000,且a^2+b^2=c^2,求a,b,c的所有自然数解? #### ...
- c++中的前置声明
引用google c++编码规范: When you include a header file you introduce a dependency that will cause your cod ...
- Java中 equals 和 == 的比较
先来看这样一个题目,假设有以下代码 下列选项中返回false的语句是? String s = "hello"; String t = "hello"; char ...
- .NetCore 使用Zipkin 分布式服务追踪监控服务性能
参考资料 https://zipkin.io/ https://github.com/openzipkin/zipkin/ https://github.com/openzipkin/zipkin4n ...
- EFCore CodeFirst 适配数据库
EF6中可以直接根据代码模型生成数据库Database.SetInitializer即可 在EFCore中如何实现呢? 这项功能放在了DatabaseFacade对象中,传入数据库上下文对象实例化到一 ...