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- ...
随机推荐
- 【译】使用OpenVAS 9进行漏洞扫描
本文译自Vulnerability Scanning with OpenVAS 9 part 1: Installation & Setup系列,本文将融合目前已经发表的四个部分. Part ...
- Thinkpad X220 升级 Windows 10 后无线网卡消失问题
11年购买的Thinkpad X220从Win7升级到Win10后,用着还是挺顺手的,网络显示等一切正常,直到今天合上盖子电脑睡眠以后再次打开,wifi消失不见.重启,关机再开机,都没用,只显示有线网 ...
- SVM Kernel Functions
==================================================================== This article came from here. Th ...
- linux笔记_day09
1.运算器.控制器.存储器.输入输出(IO) 地址总线:内存寻址 数据总线:传输数据 控制总线:控制指令 寄存器:cpu暂时存储器 2.系统设定 默认输出设备:标准输出,STDOUT,1(描述符)(显 ...
- aliyun EC2配置利用filezilla配置ftp服务
项目需要在阿里云EC2虚拟主机上配置ftp服务器,看了阿里云的教程可以使用filezilla配置,但一直遇到了一些问题.现记录一些步骤,避免以后出现类似问题. 1安装filezilla server ...
- Identical Binary Tree
Check if two binary trees are identical. Identical means the two binary trees have the same structur ...
- 解决getJSON跨域登录Session丢失的问题
最近在做项目中发现,我用下面的代码异步请求到login.ashx: var memberUrl = rooturl + 'member.ashx?r=' + Math.random() + '& ...
- ckeditor:新增时会得到上次编辑的内容
参考网址:http://blog.sina.com.cn/s/blog_6961ba9b0102wwye.html 第一次新增时没有问题,编辑器里面内容为空,编辑数据时,也是正常,但是第二次点击新增时 ...
- Java编程的逻辑 (17) - 继承实现的基本原理
本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http: ...
- .NetCore 中扩展ExceptionLess 实现链式方法添加操作日志
在使用ExceptionLess添加日志的时候,发现还是有一些写法上的个人觉得不爽的地方,比如添加Info日志 ExceptionlessClient.Default.CreateLog(source ...