使用正确的大小写和最大一个检查名称是否有效 space
Check if name is valid with Proper case and Max one space
我在网上搜索了所有正则表达式表达式,但没有找到符合我需要的。
regular expression to allow spaces between words
Regular expression to allow alphanumeric, max one space etc
Regex, every non-alphanumeric character except white space or colon
在非上述情况下,我得到了解决方案:
I need to check the Nam is valid if
=> First letter every word should be caps
=> Rest all letters of each word should be small
=> Name should have only alpha char A-Z and a-z
=> First word Length should be min 3
=> Name shud not have more than one space between words
例如:
sujay => 假
苏杰 => 真
苏杰你 => 假
Sujay U => 真
Sujay U n => false
Sujay U N => 真
苏杰 U => 假
Sujay UN => false
Sujay Uls => 真
Sujay9 => 错误
苏 => 假
苏 U => 假
Sujay U N => 真
Sujay Uls Nat=> 真
|*|检查使用的功能:
static boolean chkNamVldFnc(String namVar)
{
String namRegExpVar = "[A-Z][A-Za-z ]{2,}";
Pattern pVar = Pattern.compile(namRegExpVar);
Matcher mVar = pVar.matcher(namVar);
return mVar.matches();
}
|*|尝试 1:
String namRegExpVar = "[A-Z][A-Za-z ]{2,}";
|*|尝试 2 :
String namRegExpVar = "[A-Z][a-z]{2,}+//s[A-Z][a-z]{2,}";
|*|尝试 3 :
String NamRegExpVar = "[A-Z][a-z]{2,}||[A-Z][a-z]{2,}+//s[A-Z][a-z]";
请帮助我使用正确的正则表达式:
我也想知道为什么我们要用 ^ 开始 Reg Exp 并以 $
结束
尝试:
^[A-Z][a-z]{2,}(?: [A-Z][a-z]*)*$
- 名字必须以字母 A-Z 开头,后跟至少 2 个字母 a-z
- 可选地,名字后面可以有名字,由 space 分隔并以字母 A-Z 开头,然后是可选的字母 a-z
我在网上搜索了所有正则表达式表达式,但没有找到符合我需要的。
regular expression to allow spaces between words
Regular expression to allow alphanumeric, max one space etc
Regex, every non-alphanumeric character except white space or colon
在非上述情况下,我得到了解决方案:
I need to check the Nam is valid if
=> First letter every word should be caps
=> Rest all letters of each word should be small
=> Name should have only alpha char A-Z and a-z
=> First word Length should be min 3
=> Name shud not have more than one space between words
例如:
sujay => 假
苏杰 => 真
苏杰你 => 假
Sujay U => 真
Sujay U n => false
Sujay U N => 真
苏杰 U => 假
Sujay UN => false
Sujay Uls => 真
Sujay9 => 错误
苏 => 假
苏 U => 假
Sujay U N => 真
Sujay Uls Nat=> 真
|*|检查使用的功能:
static boolean chkNamVldFnc(String namVar)
{
String namRegExpVar = "[A-Z][A-Za-z ]{2,}";
Pattern pVar = Pattern.compile(namRegExpVar);
Matcher mVar = pVar.matcher(namVar);
return mVar.matches();
}
|*|尝试 1:
String namRegExpVar = "[A-Z][A-Za-z ]{2,}";
|*|尝试 2 :
String namRegExpVar = "[A-Z][a-z]{2,}+//s[A-Z][a-z]{2,}";
|*|尝试 3 :
String NamRegExpVar = "[A-Z][a-z]{2,}||[A-Z][a-z]{2,}+//s[A-Z][a-z]";
请帮助我使用正确的正则表达式:
我也想知道为什么我们要用 ^ 开始 Reg Exp 并以 $
结束尝试:
^[A-Z][a-z]{2,}(?: [A-Z][a-z]*)*$
- 名字必须以字母 A-Z 开头,后跟至少 2 个字母 a-z
- 可选地,名字后面可以有名字,由 space 分隔并以字母 A-Z 开头,然后是可选的字母 a-z