[英][Auto Select Text Between two given words in a notepad++]
I have a large text files.I have a given specific keyword [with spaces in between like "ABC DEF G"]. 我有一个很大的文本文件。我有一个给定的特定关键字[之间有空格,例如“ ABC DEF G”]。 It either occurs in the text file exactly two times or does not occur at all.
它要么在文本文件中恰好发生两次,要么根本不发生。
I want to have a notepad++ search such that all the text between these two keywords (around 300 to 1000 lines) gets selected automatically. 我想进行一个notepad ++搜索,以便自动选择这两个关键字之间的所有文本(大约300至1000行)。 I will then do some operation on this selected text via my plugin.So my first question is:
然后我将通过插件对所选文本进行一些操作,所以我的第一个问题是:
Is this autos-election possible(via regular expression or some already built plugin). 是否可以自动选择(通过正则表达式或某些已构建的插件)。
If yes ,can some one please suggest. 如果可以,请提出一些建议。
As of now I am reading entire text file to search which is time and memory consuming. 到目前为止,我正在读取整个文本文件以进行搜索,这既浪费时间又消耗内存。 Thanks.
谢谢。
Try this Regex: 试试这个正则表达式:
(?<=ABC DEF G)[\\s\\S]*(?=ABC DEF G)
Explanation: 说明:
(?<=ABC DEF G)
- Positive Lookbehind to find the position which is preceded by the text ABC DEF G
(?<=ABC DEF G)
- 向后查找正数,以查找以文本ABC DEF G
开头的位置 [\\s\\S]*
- matches 0+ occurrences of any character [\\s\\S]*
-匹配0+次出现的任何字符 (?=ABC DEF G)
- Positive lookahead to find the position immediately followed by the text ABC DEF G
(?=ABC DEF G)
- 正向查找以立即找到位置,后跟文本ABC DEF G
Output: 输出:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.