Reading at this: regular expression for first and last name
Here is my test cases:
Fail cases:
陳大文 (fail, not support international name)
Stev3 Smith (fail, contain number)
123 (fail, contain number)
@##$ smith (fail, special char)
.Mathias (fail, dot)
..Mathias (fail, dot dot)
Success cases:
Martin Luther King, Jr. (pass)
john smith (pass, javascript does str.trim())
d'Are to Beaware (pass)
Jo Blow (pass)
Steve Johnson-Smith (pass)
O Henry Smith (pass)
john & john (pass, support &)
My current solution:
const regExp = /^[\w'\-,.][^0-9_!¡?÷?¿/\\+=@#$%ˆ*(){}|~<>;:[\]]{0,}[^-]$/;
return condi = regExp.test(input)
My issue is that I cannot pass this:
.Mathias (fail, dot)
..Mathias (fail, dot dot)
and this at the same time
Martin Luther King, Jr.
Any idea?