regular express : how to exclude multiple character groups?

前端 未结 3 2081
既然无缘
既然无缘 2021-02-07 18:47

I have a set of urls :

/products

/categories

/customers

Now say a customers is named john, and I want to help john to reac

3条回答
  •  终归单人心
    2021-02-07 19:02

    This is entirely the wrong way to go about solving the problem, but it is possible to express fixed negative lookaheads without using negative lookaheads. Extra spacing for clarity:

    ^ (
    ( $ | [^/] |
      / ( $ | [^pc] |
        p ( $ | [^r] |
          r ( $ | [^o] |
            o ( $ | [^d] |
              d ( $ | [^u] |
                u ( $ | [^c] |
                  c ( $ | [^t] |
                    t ( $ | [^s] ))))))) |
        c ( $ | [^au] |
          a ( $ | [^t] |
            t ( $ | [^e] |
              e ( $ | [^g] |
                g ( $ | [^o] |
                  o ( $ | [^r] |
                    r ( $ | [^i] |
                      i ( $ | [^e] |
                        e ( $ | [^s] )))))))) |
          u ( $ | [^s] |
            s ( $ | [^t] |
              t ( $ | [^o] |
                o ( $ | [^m] |
                  m ( $ | [^e] |
                    e ( $ | [^r] |
                      r ( $ | [^s] ))))))))))
    ) .* ) $
    

提交回复
热议问题