我想编写一个以字符串“Row data =”开头并以字符串“。”结尾的正则表达式,然后删除所有不匹配的文本。我该怎么做?
示例日志文件:
[ERROR] 2016-07-01 17:17:05,263(2715503)-->[main] csvRowToObject(ApmInfoCSVDao.java:93): Error occured while parsing ApmInfo Object: usrid=2111840,
Row data=2111840 ABC XYZ EFC 1971-03-27 00:00:00.000 1971 03 27 1 111064287 1114007 SA:E1801.
java.text.ParseException: Unparseable date: "XYZ EFC"
at java.text.DateFormat.parse(DateFormat.java:357)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
[ERROR] 2016-07-01 17:17:05,325(2715565)-->[main] csvRowToObject(ApmInfoCSVDao.java:93): Error occured while parsing ApmInfo Object: usrid=2058318,
Row data=2058318 PP XX YY 1970-07-27 00:00:00.000 1970 07 27 1 111049159 1065120 SA:332.
java.text.ParseException: Unparseable date: "XX YY"
at java.text.DateFormat.parse(DateFormat.java:357)
我想获得:
Row data=2111840 ABC XYZ EFC 1971-03-27 00:00:00.000 1971 03 27 1 111064287 1114007 SA:E1801.
Row data=2058318 PP XX YY 1970-07-27 00:00:00.000 1970 07 27 1 111049159 1065120 SA:332.
这是显示所有隐藏字符(空格和TAB)之后的真实文本:
Row data=2111840<tab>ABC<tab><tab>XYZ<tab>EFC<tab>1971-03-27 00:00:00.000<tab>1971<tab>03<tab>27<tab>1<tab>111064287<tab>1114007<tab>SA:E1801.
我尝试搜索regexp ^ Row data*\. )$
,但它说0匹配
如何在Notepad ++中执行此操作?
感谢您的帮助!
答案 0 :(得分:0)
对于行的开头使用负面预测,对结尾使用负面字符类:
Search: ^((?! Row data=).*|.*[^.\s])\s*[\r\n]+
Replace: <blank>
这将删除以" Row data="
开头但不以点结尾的行,反之亦然。
使用问题中的示例输入进行测试。
答案 1 :(得分:0)
这应该有效:
查找:^(?!(\s*Row data=.+\.)).+(\n|\r)*
替换为空。