1

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

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

Aras121
  • 71
  • 7

2 Answers2

1

try this:

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

avi
  • 951
  • 9
  • 11
  • Thank you for the response, I've tried your regex on the following [link](https://regex101.com/r/F9QrT2/1). But it only matches two words, what I mean here is that the regex can match at least two or more words. In your regex that I tried it doesn't match if it's more than two words. Maybe you can adjust the regex a little more. – Aras121 Dec 22 '21 at 06:23
  • I edited the answer, is that OK? – avi Dec 22 '21 at 06:32
  • Yes it works, thank you very much for your help. – Aras121 Dec 22 '21 at 06:46
0

Demo: https://regex101.com/r/tt4H3Q/1

Pattern : [a-zA-Z]+(?: [a-zA-Z]+)+

[a-zA-Z] -> Match only alphabets

+ -> Match the pattern one or more times

hitesh bedre
  • 409
  • 2
  • 10