Skip to content Skip to sidebar Skip to footer

Regex Expression Which Match A Display Name Which Starts And End With An Alphabets

Couldn't find my exact need on SO and I'm still learning regex but this is what i have tried so far: display_name.match(/^[a-zàáèéìíòóùú]([.' -]+[a-zàáèéìíòóùú]

Solution 1:

This works

display_name.match(/^[a-zàáèéìíòóùú]([.'-]?[a-z àáèéìíòóùú]+)*$/i)

valid names

àdeola
òpaula-brian
Mr. teni teni

Invalid are

-mr white
mr--white
mr white'

Solution 2:

Use following pattern

/([a-zA-Zàáèéìíòóùú]+[a-zA-Zàáèéìíòóùú. -]+)/gm

Keep '-' at the end.

Post a Comment for "Regex Expression Which Match A Display Name Which Starts And End With An Alphabets"