Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我想匹配 4 个数字,但在它们之间我可以有空格和破折号。
允许最多 4 个数字的语法。
([0-9]){4}
如何让它忽略空格和破折号?
您可以使用以下正则表达式。
^[\s-]*(?:\d[\s-]*){4}$
演示