Monday, June 2, 2014

Create Regular Expression to accept only Alphabets

In this tutorial I will show you how to create a Regular Expression that will only contain Alphabets, I will also show how to edit the RE to accept other characters

The following regEx will only accept Alphabets

 re = /^[A-Za-z]+$/;

To Accept Alphabets + some other characters like /,.,, we can write regular expression like below

 re = /^[A-Za-z-/-,-.]+$/;



I hope it was informative for you and I would like to Thank you for reading.

No comments:

Post a Comment