【发布时间】:2015-03-08 05:22:22
【问题描述】:
在我的脚本中,'matchfile 是一个带或不带扩展名的文件名。
在我下面的文字中,可能有也可能没有[AnyText],括号之间的文字可以是任何字母数字字符。
如何匹配:
some text
\includescore{something}
\includescore{something.ext}
%\includescore{doNOT.match}
\includescore[AnyText]{something}
\includescore[AnyText]{something.ext}
more text
到目前为止,我有这个:
regexmatch(searchthis, "mi)(?<=(?<!%)\\includescore\{|(?<!%)\\includescore\[\w\]\{)[\w\s\.\+'#-]+\.?[\w\s\.\+'#-]+(?=.*\})", matchfile)
但那只能匹配:
\includescore{something}
\includescore{something.extension}
\includescore[a]{something}
如果该行以% 开头,我不想匹配。
我的第一个想法是使用 w+,但 Autohotkey 不允许未量化的后视。
实际上,我什至不关心匹配方括号。我只需要匹配\includescore、matchfile 和大括号。
还有其他方法可以做到这一点,还是我需要进行多次正则表达式调用?
【问题讨论】:
-
includescore在您的正则表达式中来自哪里?请提供一些真实的输入和预期的输出。
标签: regex autohotkey