问题描述
我的列必须包含 2 个字母和 4 个数字,像这样 (AV1234)
我该如何检查?
解决方法
您可以使用 talend 文档 here 中提到的 sql 模板,您可以使用正则表达式检查包含字母和数字的列。
使用这个[a-zA-Z]{2}[0-9]{6}
如果你只想要大写字母 [A-Z]{2}[0-9]{6}
[a-zA-Z] # Match a single character present in the list below
# A character in the range between “a” and “z”
# A character in the range between “A” and “Z”
{2} # Exactly 2 times
[0-9] # Match a single character in the range between “0” and “9”
{6} # Exactly 6 times
,
谢谢你的回答! 它有效
我的日常代码:
public static Boolean MyPattern(String str) {
String stringPattern = "[A-Z]{2}[0-9]{4}";
boolean match = Pattern.matches(stringPattern,str);
return match ;
}