是否有突出显示 findstr 匹配字符的应用程序
Is there an application which highlights findstr matching characters
我正在处理一个文件列表,其中包含 date/time 个邮票。
它们有两种可能的格式:
YYYY/MM/DD hh:mm:ss
YYYY-MM-DD hh:mm:ss
我想知道今天十二点半开始的条目是什么。
为此,我编写了以下正则表达式:
"2017[-/]09[-/]12 12:3[0-9]:[0-9][0-9]"
含义如下:
- 在年月日之间我们可能有两个可能的字符,
因此
[-/]
- 时间戳应该类似于“12:3x:xx”(某处
在 12:30 之后,但不超过 10 分钟),所以我使用了
[0-9]
.
- 分号将被视为普通字符,但由于它们没有嵌入方括号
[
或 ]
内,我决定简单地将它们写成不带转义字符(是否有顺便说一句,findstr
的转义字符?)。
令我惊讶的是,以下条目似乎适合:
2017/09/12 13:14:36.777|__logfile_|13240|17508|CClass::Function|CRU|-1|** Releasing critical section m_Busy
2017/09/12 13:14:36.777|__logfile_|13240|17508|CClass::Function|CRU|-1|** Done with Function
我不知道哪些字符遵守我写的正则表达式,显然我不想在我遇到的每个问题上写一个 Whosebug post findstr
,因此我会想知道:有没有什么工具可以验证 findstr
正则表达式并突出显示结果(这样我就可以逐步学习如何更正我的表达式)?
你的正则表达式适合我。你没说你是怎么打电话的 findstr
您需要 /R
(正则表达式)和 /C
(文字字符串)标志:
findstr /R /C:"2017[-/]09[-/]12 12:3[0-9]:[0-9][0-9]" logfile.txt
我正在处理一个文件列表,其中包含 date/time 个邮票。
它们有两种可能的格式:
YYYY/MM/DD hh:mm:ss
YYYY-MM-DD hh:mm:ss
我想知道今天十二点半开始的条目是什么。
为此,我编写了以下正则表达式:
"2017[-/]09[-/]12 12:3[0-9]:[0-9][0-9]"
含义如下:
- 在年月日之间我们可能有两个可能的字符,
因此
[-/]
- 时间戳应该类似于“12:3x:xx”(某处
在 12:30 之后,但不超过 10 分钟),所以我使用了
[0-9]
. - 分号将被视为普通字符,但由于它们没有嵌入方括号
[
或]
内,我决定简单地将它们写成不带转义字符(是否有顺便说一句,findstr
的转义字符?)。
令我惊讶的是,以下条目似乎适合:
2017/09/12 13:14:36.777|__logfile_|13240|17508|CClass::Function|CRU|-1|** Releasing critical section m_Busy
2017/09/12 13:14:36.777|__logfile_|13240|17508|CClass::Function|CRU|-1|** Done with Function
我不知道哪些字符遵守我写的正则表达式,显然我不想在我遇到的每个问题上写一个 Whosebug post findstr
,因此我会想知道:有没有什么工具可以验证 findstr
正则表达式并突出显示结果(这样我就可以逐步学习如何更正我的表达式)?
你的正则表达式适合我。你没说你是怎么打电话的 findstr
您需要 /R
(正则表达式)和 /C
(文字字符串)标志:
findstr /R /C:"2017[-/]09[-/]12 12:3[0-9]:[0-9][0-9]" logfile.txt