I am trying to find all text blocks in a file, that contain a string, matching the following regex: D[:\/\\]+Apps[\/\\]+
and are surrounded by double newlines.
For example in this text:
00,36,00,31,00,39,00,33,00,34,00,65,00,30,00,38,00,39,00,00,00,00,00,00,00,\
00,00,00,00,00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\NGenService\Roots\D:/Apps/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/Architecture Tools/GraphProviderPackage/Microsoft.VisualStudio.GraphProviderPackage.dll]
"Status"=dword:00000003
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\NGenService\Roots\D:/Programs/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/Architecture Tools/GraphProviderPackage/Microsoft.VisualStudio.GraphProviderPackage.dll\0]
"Scenario"=dword:00000020
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2....
What I want to be found is:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\NGenService\Roots\D:/Apps/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/Architecture Tools/GraphProviderPackage/Microsoft.VisualStudio.GraphProviderPackage.dll]
"Status"=dword:00000003
Having in mind, that "Status"=dword:00000003
is on a different line
So far this is the closest I got:
\r?\n\r?\n(([\s\S](?!\r?\n\r?\n))*)D[:\/\\]*Apps[\/\\]*(([\s\S](?!\r?\n\r?\n))*).\r?\n\r?\n
but Notepad++ says that my regex is invalid, even though in regex101 it matches it the way I want it.
\R\R\K\[.+?D:/Apps/.+?(?=\R\R)
. matches newline
Explanation:
\R\R # 2 any kind of linebreak
\K # forget them
\[ # openning square bracket
.+? # 1 or more any character, not greedy
D:/Apps/ # literally
.+? # 1 or more any character, not greedy
(?=\R\R) # poritive lookahead, make sure we have 2 linebreak after
Screenshot: