Html regex pattern: [\d\s-]{3} works but [\d-\s]{3} doesn't. Why?

前端 未结 2 1393
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 02:51

Codepen example:
https://codepen.io/Trost/pen/KXBRbY
Try putting 1 symbol in both fields.
I can\'t get what\'s wrong. If I test these regex in https://regex101.com,

2条回答
  •  后悔当初
    2021-01-27 03:23

    You define two different things:

    • [a-z] is a definition of a range - all characters from a to z.
    • [az-] is a definition of a set of three elements - a, z and -.

提交回复
热议问题