Notepadd ++ REGEX标记1行向上和1行向下

时间:2018-08-09 06:42:08

标签: regex notepad++

我有数百个长文本文件,其中包含如下信息:

Lorem Ipsum is simply dummy text of the printing and typesetting industry
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
when an unknown printer took a galley of type and scrambled it to make a type specimen book
It has survived not only five centuries, but also the leap into electronic typesetting
remaining essentially unchanged
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested
Six Dragon is at Platinum Cineplex Singapore.
July 6, 2017 Singapore
more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum ... 
Lorem Ipsum is simply dummy text of the printing and typesetting industry
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
Six Dragon
July 27 at 8:53 AM
Lorem Ipsum is simply dummy text of the printing and typesetting industry

该行很长(将近1000行)。

我要复制到剪贴板/标记包含该行的所有信息:

Six Dragon is at Platinum Cineplex Singapore.
July 6, 2017 Singapore
more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum ...

Six Dragon
July 27 at 8:53 AM
Lorem Ipsum is simply dummy text of the printing and typesetting industry

或者在其他选项中,我要标记日期前1行和日期后1行的所有文本

/ * 到目前为止,这是我的进度: * /

6月15日

(?m)(^[^\r\n]*\R+){1}(^[a-zA-Z]+ \d{1,2}\r)[^\r\n]*\R+(^[^\r\n]*\R+){1}

2017年1月12日

(?m)(^[^\r\n]*\R+){1}(^[a-zA-Z]+ \d{1,2}, \d{1,4})[^\r\n]*\R+(^[^\r\n]*\R+){1}

6月27日31:26

(?m)(^[^\r\n]*\R+){1}(^[a-zA-Z]+ \d{2} at \d{1,2}:\d{1,2})[^\r\n]*\R+(^[^\r\n]*\R+){1}

5月27日新加坡

(?m)(^[^\r\n]*\R+){1}(^[a-zA-Z]+ \d{2} [a-zA-Z]+\r)[^\r\n]*\R+(^[^\r\n]*\R+){1}

如何将这些结果复制-粘贴到剪贴板,以及如何对其他文件进行循环播放?

请帮助我,非常感谢。

1 个答案:

答案 0 :(得分:0)

您可以尝试以下方法:

.*\r?\n[JFMASOND]\w+\h*\d{1,2}\h*(?:,?\h*(?:\d{4})?\h+\w+|at\h*\d{1,2}:\d{1,2}\h*(?:\h+AM|\h+PM:)?)?\h*\r?\n.*

Demo

如果要删除除这些行以外的所有内容,请改用此方法:

([^\n]*\r?\n[JFMASOND]\w+\h*\d{1,2}\h*(?:,?\h*(?:\d{4})?\h+\w+|at\h*\d{1,2}:\d{1,2}\h*(?:\h+AM|\h+PM:)?)?\h*\r?\n.*)|[^\n]*

替换为:$1

Demo