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.
我想要一个正则表达式来检查字符串是否只包含大写和小写字母、数字、电话、电子邮件,特殊例如:“[AC,@#!]”
我可以在一个正则表达式中拥有所有这些吗?
试试RegexLib.com
电子邮件:\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
电话#:^[0-9]\d{2}-\d{3}-\d{4}$
^[0-9]\d{2}-\d{3}-\d{4}$
不,您不太可能为您提到的每一种非常不同的场景编造一个“一刀切的正则表达式”。