Regular expression: find range except for one letter or a range

前端 未结 2 999
忘了有多久
忘了有多久 2020-11-30 14:22

How can I use the negation within square brackets as an exception, to find e. g. everything between a-z except for the the range from m-o? [a-z^m-o]?

By

2条回答
  •  离开以前
    2020-11-30 14:49

    You should be able calculate the difference yourself.

    [a-lp-z]
    

    If the regex engine supports lookahead assertion, you could use

    (?![m-o])[a-z]
    

    but this would probably be less efficient.

提交回复
热议问题