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- ...
随机推荐
- Javascript - Vue - vue对象
vue提供了一整套前端解决方案,可以提升企业开发效率 vue的处理过程 app.js 项目入口,所有请求最先进入此模块进行处理 route.js 由app.js调用,处理路由的分发 controlle ...
- Linux那些事儿之我是Hub(大结局)挂起自动化【转】
转自:http://blog.csdn.net/fudan_abc/article/details/1805471 目睹了当今大学校园的素质流氓化,kiss公开化,消费白领化,上课梦游化,逃课普遍化, ...
- MySql 死锁时的一种解决办法【转】
转自:http://blog.csdn.net/mchdba/article/details/38313881 之前也遇到一次,今天又遇到了这个问题,所以这次必须解决,网上找到这篇文章帮了大忙,方便以 ...
- Winform/WPF Clipboard之剪切复制粘贴
Winform // <summary> /// 复制或剪切文件至剪贴板(方法) /// </summary> /// <param name="files&q ...
- oracle锁表查询,资源占用,连接会话,低效SQL等性能检查
查询oracle用户名,机器名,锁表对象 select l.session_id sid, s.serial#, l.locked_mode, l.oracle_username, l.os_user ...
- tomcat报错:java.net.SocketException: Permission denied["http-nio-80"]
tomcat报错:java.net.SocketException: Permission denied["http-nio-80"] 问题:使用非root账户tomcat启动to ...
- Java 连接远程Linux 服务器执行 shell 脚本查看 CPU、内存、硬盘信息
pom.xml jar 包支持 <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch& ...
- .NetCore 下使用多个DbContext
一个项目中使用多个DbContext 或者种数据库的多个DbContext 业务需要 单个DbContext使用不需要给出说明 1.dotnet ef migrations add migration ...
- 说commit,rollback
事务执行失败后,看做的是commit还是rollback:commit是把执行成功的部分提交了,rollback就是全回滚了.如果rollback失败了,此时不处理,等到客户端断开,MySQL内部默认 ...
- 【LOJ】#2886. 「APIO2015」巴厘岛的雕塑 Bali Sculptures
题解 感觉自己通过刷水题混LOJ刷题量非常成功 首先是二进制枚举位,判是否合法 要写两个solve不是很开心,\(A\)不为1的直接记录状态\(f[i][j]\)为能否到达前\(i\)个分成\(j\) ...