【发布时间】:2018-09-12 07:17:26
【问题描述】:
我遇到了以下正则表达式模式的问题:
m).*?^([^n]*)(modified)([^n]*)$.*
我想用
替换剪贴板Clipboard := RegExReplace(Clipboard, "m).*?^([^n]*)(modified)([^n]*)$.*" ,"" )
来源看起来像:
Interesting 326 Featured
Hot Week Month 1 vote 0 answers 12 views
Type Guard for empty object
typescript modified 2 mins ago kremerd 312
0 votes
预期结果应该是:
typescript modified 2 mins ago kremerd 312
但它什么都没有。如果这可行,我想稍后使用 regExMatch 获取标记名 ^([^n]*)。
我正在使用来自https://autohotkey.com 的自动热键(Windows 开放源)编写脚本
【问题讨论】:
-
在我看来,您想将非换行符与
[^\n](而不是[^n])匹配。此外,您需要通过添加s修饰符使.匹配换行符。试试sm).*?^([^\n]*modified[^\n]*)$.* -
另外,在我看来,您只需要
FoundPos := RegExMatch(Clipboard, ".*modified.*", res) ;并通过res[0]获取行值。 -
试试
^(.+)modified(.+)$ -
@WiktorStribiżew 我想要第一行。因此我使用你的小修改:
FoundPos := RegExMatch(Clipboard, ".*?(modified).*", res) ; MsgBox,% res[0] " = res[0]"但我现在得到了结果。它是空的嗯。
标签: regex autohotkey