英文:
bean-validation @Pattern the first digit is '1'
问题
如何在以下字段中使用 bean-validation 的 @Pattern 进行验证,以检查第一个数字是否为 '1'?
private Long registration;
英文:
How to use bean-validation @Pattern in the field below to check if the first digit is '1'?
private Long registration;
答案1
得分: 1
以下是翻译好的内容:
正则表达式如下,它表示必须以1开头,之后可以是任何内容:
@Pattern(regexp = "^1.*$")
private Long registration;
英文:
Regex bellow says it must start with 1 and have anything after that
@Pattern (regexp = "^1.*$")
private Long registration;
专注分享java语言的经验与见解,让所有开发者获益!
评论