在 Autohotkey 中使用正则表达式提取代码
Extracting code using regex in Autohotkey
我正在尝试使用 Autohotkey(即“变量 <- 123”,第 4 行没有开头“#”)从注释中提取 R 代码。示例文本是:
# this is comment 1
# this is comment 2
# this is comment n
variable <- 123
我尝试了以下正则表达式,但没有按预期工作。任何建议将不胜感激。谢谢!
^(?<!#)(.*?)$
The results in AHK Regex tester
解决方案
^[^#\n]+$
说明
^
匹配新行或字符串的开头
[^#\n]
匹配不是散列或换行符的字符
+
匹配一个或多个上述标记
$
匹配行尾或字符串
我正在尝试使用 Autohotkey(即“变量 <- 123”,第 4 行没有开头“#”)从注释中提取 R 代码。示例文本是:
# this is comment 1
# this is comment 2
# this is comment n
variable <- 123
我尝试了以下正则表达式,但没有按预期工作。任何建议将不胜感激。谢谢!
^(?<!#)(.*?)$
The results in AHK Regex tester
解决方案
^[^#\n]+$
说明
^
匹配新行或字符串的开头[^#\n]
匹配不是散列或换行符的字符+
匹配一个或多个上述标记
$
匹配行尾或字符串