使用正则表达式获取第一个问题的标签名称
Get tag name of the first question by using regex
我遇到了以下正则表达式模式的问题:
m).*?^([^n]*)(modified)([^n]*)$.*
我想用
替换剪贴板
Clipboard := RegExReplace(Clipboard, "m).*?^([^n]*)(modified)([^n]*)$.*" ,"" )
来源看起来像:
Ask Question 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
的 autohotkey(windows 开源)编写脚本
您想匹配包含 modified
子字符串的行。默认情况下,正则表达式中的点不匹配换行符,因此您需要传递 s
(DOTALL) 修饰符(您可以将其与 m
、MULTILINE 修饰符一起添加,使得 ^
匹配字符串开始位置, $
匹配行结束位置)。此外,要匹配非换行符,您需要 [^\n]
(而不是 [^n]
)。
要解决您可以使用的问题
RegExMatch(Clipboard, "s)^.*?(\n[^\n]*)(modified|asked|answered)", res)
通过 res
获取整行值,通过 res1
获取关键字前的文本,通过 res2
.
获取关键字本身
详情
s)
- .
现在匹配任何字符,包括换行字符
^
- 字符串的开头
.*?
- 任何 0+ 个字符,尽可能少
(\n[^\n]*)
- 第 1 组(稍后通过 res1
访问):换行符后跟除换行符以外的 0+ 个字符
(modified|asked|answered)
- 三个选项中的任何一个:modified
、asked
或 answered
.
我遇到了以下正则表达式模式的问题:
m).*?^([^n]*)(modified)([^n]*)$.*
我想用
替换剪贴板Clipboard := RegExReplace(Clipboard, "m).*?^([^n]*)(modified)([^n]*)$.*" ,"" )
来源看起来像:
Ask Question 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
的 autohotkey(windows 开源)编写脚本您想匹配包含 modified
子字符串的行。默认情况下,正则表达式中的点不匹配换行符,因此您需要传递 s
(DOTALL) 修饰符(您可以将其与 m
、MULTILINE 修饰符一起添加,使得 ^
匹配字符串开始位置, $
匹配行结束位置)。此外,要匹配非换行符,您需要 [^\n]
(而不是 [^n]
)。
要解决您可以使用的问题
RegExMatch(Clipboard, "s)^.*?(\n[^\n]*)(modified|asked|answered)", res)
通过 res
获取整行值,通过 res1
获取关键字前的文本,通过 res2
.
详情
s)
-.
现在匹配任何字符,包括换行字符^
- 字符串的开头.*?
- 任何 0+ 个字符,尽可能少(\n[^\n]*)
- 第 1 组(稍后通过res1
访问):换行符后跟除换行符以外的 0+ 个字符(modified|asked|answered)
- 三个选项中的任何一个:modified
、asked
或answered
.