我必须在日志文件中找到多个日志文件条目。返回必须包括以下内容()()因此与 Weber Tom (PRD) (PRD) 一致;但与 Huser Andri (PRD) 不一致
- - 日志档案 - -
DEBUG - [2022-04-16 04:47:06,337] - [30] Get-AdUserProperty - existingDisplayName=Weber Tom (PRD) (PRD)
DEBUG - [2022-04-16 04:47:06,337] - [37] Get-AdUserProperty - existingDisplayName=Huser Andri (PRD)
DEBUG - [2022-04-16 04:47:06,353] - [35] changePostalAddress: False
DEBUG - [2022-04-16 04:47:06,353] - [35] PostalAddress.Street: Bäckerstrasse
DEBUG - [2022-04-16 04:47:06,353] - [35] changeOfficeAddress: False
问题是 Regex 无法搜索 ()。这是因为 Regex 函数被阻止了。此外,一行中带有 .* 的多个单词对此不起作用。
我如何才能找到这样的条目
(PRD) (PRD)
或者
(PRI) (PRI)strong text
或者
(PRO) (PRO)
希望你明白我的意思......
答案1
- Ctrl+F
- 找什么:
^.*(\(.+?\))\h+\1.*$
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Find All in Current Document
解释:
^ # beginning of line
.* # 0 or more any character but newline
( # start group 1
\( # openning parens, have to be escaped
.+? # 1 or more any character but newline, not greedy
\) # closing parens
) # end group 1
\h+ # 1 or more horizontal spaces
\1 # backreference to group 1 (i.e. the same value)
.* # 0 or more any character but newline
$ # end of line