You can try it like this:
import javax.validation.constraints.Pattern;
public class Variable {
private String id;
@Pattern(regexp = "^[a-zA-Z0-9_]{1,256}$")
private String name;
public Variable() {
}
// getter/setter ..
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…