开发者

Validate name and surname using regex

开发者 https://www.devze.com 2023-02-05 08:17 出处:网络
I am trying to write a regex for name and surname. They are made by one or more words that can be made only by alphabetical letter (I don\'t care initial capital letters).

I am trying to write a regex for name and surname. They are made by one or more words that can be made only by alphabetical letter (I don't care initial capital letters).

I would like to match for both name and surname:

Names:

- Antony de Home April
- antony de Home April
- ANTONY de Home ApRil
- aNtOnY de Home April
- Antony de d'home APRil
- Antony de d'Home ApRil
- Antony de D'Home April
- Antony de d'HOME AprIL
- ...

Surname match the same cases as names.

I would not (no numbers or special characters):

Names:

- Antony1 de Home Ap*ril
- Antony_ de Home Apr+il
- Ant_ony de Home Apr#il
- Antony@ de Ho@me Apr^il
- ...

Surname match the same cases as names.

How I can write that?


UPDATE

I would like to match fo开发者_运维百科r both name and surname:

Names:

- Antòny de Homé April
- àntony de Home ùpril
- Antony de Home Aprìl

If you have other suggestions for name and surname validation, let me look!


This sould be your regex:

[A-Za-z]+\s+['A-Za-z]+


/([a-Z]+)\s([a-Z]+)/

of course I make a number of assumptions with this regex.

0

精彩评论

暂无评论...
验证码 换一张
取 消