How should like a regex which validates the name and surname, so that each word starts with a capital letter?
this does not work: @”[^A-Z]?[a-z]*”
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
Note that this is, however, not a good way to validate names. Depending on the locale, non-ASCII UTF8 characters may be used. Also, not all names start with an uppercase letter. The following names exist in the real world:
Hence, this is a little better – it just makes sure that each character is a valid letter:
That said, the best way to do this may depend on the implementation of the regular expression engine, so we’d need to know the language and/or regex library that you are using.
Edit based on your answer: If you need to parse both fields at the same time, try this: