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.
名称必须介于 2 到 25 个字符之间,并且只能包含一个空格、连字符或撇号,因为我使用了给定的代码,但它不能正常工作。^[a-zA-Z]{2}[a-zA-Z-\s']*$
您可以使用前瞻来检测表达式中恰好有零个或一个这样的字符:
/^(?=^[^\s'-]*[\s'-]?[^\s'-]*$)[a-zA-Z\s'-]{2,}$/