Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to match two or more words name in javascript regex?

I’m trying to verify that there are at least two words name, where a word is only alphabet for example:

// Should pass
Jean Acker 
Mary Kay Adams
Elizabeth Allen Alba Bailey
Blanche Baker Bowen Collinge Marie
// ...and so on more than two words

// Should Fail
Ryan
Filbert77
Mark 21
Franz.Dimaz

This is the regex I’m currently using just to verify letters and spaces

/^[aA-zZ\s]+$/

I have searched and tried one of them on this link but it didn’t work link

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Can anyone help me to verify name more than 1 word?

>Solution :

try this:

([a-zA-Z]{1,})+\s+([a-zA-Z]{1,})+[a-zA-Z\s]*

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading