Wednesday 13 February 2013

Regex for Name validation with atleast one alpahbet(A-z)


^[a-zA-Z0-9]*[a-zA-Z]+[a-zA-Z0-9]*$

To explain: The bit in the middle square brackets (the "meat in the sandwich") matches an alphabet character.
The + after it makes sure there is at least one of these.
The other two square-bracketed expressions (the "bread in the sandwich") match alphanumeric characters.
The * after each allow any number of these.
The ^ and $ surrounding the whole thing make sure it is the whole text being looked at and not just part of it.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete