这是我所做的
[a-zA-Z][a-zA-z(\. | \s)]+[a-zA-Z]$
但是我到底想要什么。
表达接受:
开始时
1- Start with non-space character(A-za-z)
Middle
2- Spaces between words are allowed(\s)
3- dot(.) is allowed between chars only once, and occurs only, after any non-space character(A-za-z)
4- Same as 3, but dot is replaced by dash(-)
5- And if dash found the expression accept only, non-space char(A-za-z) and first char should be in uppercase.
结尾为
6- Any non-space char(A-za-z)
示例:
a. M. john
b. M john
c. M-John
d. M. john-Rich
如果不是
Suggest how much it can possible
尝试(?i)^(?!.*\..*\.)(?!.*-.*-)[a-z](?:[a-z ]|(?:(?<=[a-z])-(?=[a-z]))|(?:(?<=[a-z])\.))+$