因此,对于PCRE(PHP)正则表达式,我试图从开发团队的主机平台上读取搜索的输出。
我需要解析出文件名,这样我就可以加入到我正在跟踪系统迁移细节的其他列表中。
到目前为止,我的表达式在Regex101.com上。此处 与样本数据.我确信还有更多的效率我可以引入,但现在我希望在走这条路之前满足要求。
以下是参考代码
^(?#
Objective is to capture the first two columns: program name and line number. This part is easy
I'm able to skip lines with comments and start parsing at the 'QRY' string.
Challenge is I would like to skip lines like this
.*\/\*QRY.*$
and include lines like this [end comment appears before the 'QRY' string]
.*\/\*.*\*\/QRY.*$
Check for comment indicator and skip lines with comments
)(?!.*\/\*.*(?!\*\/)QRY)(?#
)(?#
Program name
)^(?<prgName>.+?)[[:blank:]](?#
QRY clause
)(?:.*QRY\((?<qryName>.*?)\))*(?#
FILE or QRYFILE clause
)(?:.*FILE\(\((?<qryFile01>.*?)\)(?:[[:blank:]]\((?<qryFile02>.*?)\)\))*)*
试试 '~(?mi)(?:(?:^.*?/\*(?:(?!\*/).)*QRY.*$(*SKIP)(*FAIL))|^(?<prgName>.+?)[[:blank:]](?:.*QRY\((?<qryName>.*?)\))*(?:.*FILE\(\((?<qryFile01>.*?)\)(?:[[:blank:]]\((?<qryFile02>.*?)\)\))*)*)~'
特征