regex - Need help to find a regular expression for name and last name validation -


i tried find same problem, didn't find anything.

i need 2 separate regular expressions, 1 names, , 1 last names.

here rules names:

  • a name can't start spaces, numbers or other symbol.
  • a name must long @ least 3 characters, maximum of 15 characters.
  • no symbols allowed.

some allowed name examples:

malcolm walter bob

giovanni francesco

steven

here last names rules:

  • a last name can't start spaces, numbers or other symbol.
  • a last name must long @ least 3 characters, maximum of 15 characters.
  • a last name can contains apostrophes, dots , dash.

some allowed last names examples:

d'addario

berners lee

berners lee

o'riley.

thanks in advance help!

first name:

[a-za-z.\-']+ 

last name:

[a-za-z.\-' ]{3,15} 

combined:

[a-za-z.\-' ]+ [a-za-z.\-']{3,15} 

keep in mind restriction on last names strict - you'll rule out many asian last names li or wu.

also, i'm not sure, if wanted make last name optional. if so:

[a-za-z.\-' ]+ (?:[a-za-z.\-']{3,15})? 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -