【发布时间】:2015-03-10 15:00:22
【问题描述】:
考虑以下字符串和我正在使用的正则表达式:
start match the target if stop appears before the next start
(?<=start.*)target(?=.*stop)
如果 target 出现在单词 start 之后和单词 stop 之前,我将匹配它。但是,我需要知道如何修改前瞻,以使 target 仅在 start 没有出现在 target 和 stop 之间时才匹配。例如,以下字符串不应导致匹配:
start don't match the target if the next start appears before stop
如果有以下stop但没有下一次出现start,也需要匹配:
start match the target if stop appears afterward without a next occurrence
【问题讨论】: