Hello, Hello, everyone! I am a programmer hooligan! Today to share with you the main project met last week, and a plurality of strings check only keep repeating field data of a SQL writing.
A, it is determined whether or kanji character string
1, it is determined whether the character string comprising characters
public boolean checkcountname(String countname)
{
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(countname);
if (m.find()) {
return true;
}
return false;
}
2, it is determined whether the character string is composed of Chinese
public boolean checkname(String name)
{
int n = 0;
for(int i = 0; i < name.length(); i++) {
n = (int)name.charAt(i);
if(!(19968 <= n && n <40869)) {
return false;
}
}
return true;
}
3. Reference Site: https://blog.csdn.net/changjiale110/article/details/78915969
Two, UUID check
1, a method of producing a UUID
public static UUID getRandomUUID(String str) {
// generate UUID
if (str == null) {
return UUID.randomUUID();
} else {
return UUID.nameUUIDFromBytes(str.getBytes());
}
}
2, it is determined whether the UUID
public static boolean isValidUUID(String uuid) {
// UUID check
if (uuid == null) {
System.out.println("uuid is null");
}
String regex = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
if (uuid.matches(regex)) {
return true;
}
return false;
}
3. Reference Site: https://blog.csdn.net/Kangyucheng/article/details/86498341
Three, the SQL plurality of repeating a data field is reserved only
SELECT * FROM test1 GROUP BY factory_name,model_name,hard_version HAVING count(*)>=1
Reference website: https://blog.csdn.net/sxf_123456/article/details/77509201
Fourth, time share