Html regex pattern: [\d\s-]{3} works but [\d-\s]{3} doesn't. Why?
问题 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, they appear to be identical. <form> Works: <input type="text" name="country_code" pattern="[\d\s-]{3}" title="-23" required> <input type="submit"> </form> <form> Bug: <input type="text" name="country_code" pattern="[\d-\s]{3}" title="- 3" required> <input type="submit"> </form> 回答1: The real root cause here is that the regex [\d-\s]