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.
@NotNull @Pattern(regexp="[[:Alpha:]]+", message="Only Alphabetic chars allowed") protected String name;
这仅允许 aaaa 作为输入,例如尝试将字符串设置为“apple”dosent 工作。但是将字符串设置为“aaaaaa”工作。我只想允许字母字符。
你可以使用:
@Pattern(regexp="\\p{Alpha}+", message="Only Alphabetic chars allowed")