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.
我在 ASP.NET 客户端验证器中使用这个 RegEx:
\d{9}|A\d{8}|a\d{8}
它成功地匹配了这些字符串(这是我想要的):
123456789 a12345678 A12345678
但是现在RegEx 中有一个我不喜欢的重复部分——有没有更简洁的方法呢?A\d{8}|a\d{8}
A\d{8}|a\d{8}
使用正则表达式模式[aA\d]\d{8}
[aA\d]\d{8}
使用\d{9}|[Aa]\d{8}. [Aa]将匹配“A”或“a”。
\d{9}|[Aa]\d{8}
[Aa]