简体   繁体   English

在记事本++中进行多行搜索

[英]Multiple Line Search in Notepad++

I'm looking for a way to identify a missing record within a record group in Notepad++. 我正在寻找一种在Notepad ++中的记录组中标识丢失记录的方法。 Each record group begins and ends with a tilde. 每个记录组以波浪号开头和结尾。 However, some groups are missing the detail record (H1 record). 但是,某些组缺少明细记录(H1记录)。 In the example below, I need to find the bold/italicized entries. 在下面的示例中,我需要找到粗体/斜体条目。

~H1~,10222,30333,JONES 〜H1〜,10222,30333,JONES
MIDWEST EMERGENCY, 123456 中午紧急情况,123456
~
~H1~,30334,3234543,SMITH 〜H1〜,30334,3234543,SMITH
MIDWEST EMERGENCY,933233 中午紧急情况,933233
~
MIDWEST EMERGENCY,92345434 中部紧急状态,92345434
~
~H1~,3232353434,232343534,HORST 〜H1〜,3232353434,232343534霍斯特
MIDWEST EMERGENCY,223342545 中部紧急情况,223342545
~
EASTERN EMERGENCY,2334333 东部紧急状态,2334333
~
~H1~,3055543,33232322,VICE 〜H1〜,3055543,33232322,VICE
SOUTHERN EMERGENCY,233446655 南部紧急状态233446655
~

Something like this should do it: 这样的事情应该做到:

/~\n[A-Z]+[ ]+EMERGENCY[, ][0-9]+\n~/g

First match for "~", then newline, then a string in caps, space, EMERGENCY, comma, number, newline tilda 首先匹配“〜”,然后是换行符,然后是大写字母,空格,紧急情况,逗号,数字,换行符tilda

Experiment here: https://regex101.com/ 在此处进行实验: https//regex101.com/

Next time post your attempts 下次发布您的尝试

If you're in the "Extended" mode of Find (or Find and Replace) you should be able to use a combination of \\n (for Unix format files) or \\r\\n (for DOS/Windows format files) to match one newline character. 如果您处于“查找”(或“查找和替换”)的“扩展”模式,则应该可以使用\\n (对于Unix格式文件)或\\r\\n (对于DOS / Windows格式文件)的组合来进行匹配一个换行符。 It should then be possible to put the rest of your search pattern before or after that token to search across multiple lines. 然后应该可以将其余的搜索模式放在该标记之前或之后,以进行多行搜索。

This seems to work 这似乎有效

~\n([^~]*)\n~

Matches the tilda, newline, then anything that doesn't have a tilda in it before the next new line character and tilda. 匹配tilda,换行符,然后匹配下一个新行字符和tilda之前没有tilda的所有内容。

The parenthesis around the [^~]* bind it to /1 if you want to use that 如果要使用[^〜] *括号将其绑定到/ 1

[~]\\r\\n[^~] [〜] \\ r \\ n [^〜]

This did the trick. 这成功了。 Thanks for all of the suggestions above. 感谢上述所有建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM