Page 1 of 1

Regular Expression allow alpha characters only?

Posted: Sat Jan 28, 2012 11:56 pm
by bobbygerez
Hi everyone, I've search google about regular expression that accept alpha characters only and there are alternatives
name starts with an upper case letter:
var re = /^[A-Z][A-Za-z]*$/
var re = /^[A-Z][A-Za-z]{2,}$/ /* to insist on upper case first letter */

I'm a beginner on javascript and I don't know how this code goes on. I know this one works with alpha but I need to know what is test. If I know what is test then I can try this code.Thanks.

Code: Select all

var name1 = "Bob1";
var name2 = "Bob";

function isValidFirstName(fn)
    var re = /^[a-z]+$/i;
    return re.test(fn);


Re: Regular Expression allow alpha characters only?

Posted: Tue Aug 05, 2014 12:02 am
by WebOutGateway

.test is a Javascript method that checks or tests for a match in the string.

It will return true if it has match/es and false if none.

I hope this helps. Thank you.

Tue Aug 05 2014 11 02 am

Posted: Wed Jun 17, 2015 11:56 pm
by Haddep36
I apologise, but, in my opinion, you are mistaken. Let's discuss it. Write to me in PM.