- It only allows letters including ñ and Ñ
- doesn't allow other special character besides comma and dot
- doesn't allow 2 consecutively dot and comma in any part of the name
What should I add to my regex?
^[a-zA-Z]+$
What should I add to my regex?
^[a-zA-Z]+$
I would phrase your regex as:
^(?!.*[.,]{2})[A-Za-zñÑ.,]+$
Explanation:
^ from the start of the string(?!.*[.,]{2}) assert that no consecutive dots or commas occur[A-Za-zñÑ.,]+ match a letter, including ñ and Ñ, dot or comma, one or more times$ end of the string