【问题标题】:Accept specific word but negate if you have another specific word together接受特定的词,但如果你有另一个特定的词一起否定
【发布时间】:2018-07-11 07:30:19
【问题描述】:

我知道我可以用否定前瞻来否定特定单词 - 所以在我的示例中,我如何否定实际的“/checkout/payment”但仅在有单词“/checkout/”时才接受?

我到底需要什么:
/itempage/ - 不匹配
/product/model - 不匹配
/checkout/ - 匹配
/checkout/shipping - 匹配
/checkout/payment - 不匹配

【问题讨论】:

标签: regex regex-negation


【解决方案1】:

您的问题不够清楚,无法明确说明您想要什么。但在 Javascript 中:

/^\/checkout\/(?!payment)/

这将匹配 /checkout//checkout/shipping/checkout/other,但不匹配 /checkout/payment/checkout/paymentABC

【讨论】:

    猜你喜欢
    • 2013-05-19
    • 1970-01-01
    • 2010-12-22
    • 1970-01-01
    • 2014-08-13
    • 1970-01-01
    • 1970-01-01
    • 2017-11-14
    • 1970-01-01
    相关资源
    最近更新 更多