Regular Expression

L

Lars Nilsson

I need to check that the user as put in at least one character between
a-z upper or lowercase in a name field. They can put in whatever they
like but there as to be a character a-z in the string. How shall the
test expression look like?

/Lars
 
J

Jacob Heider

I need to check that the user as put in at least one character between a-z
upper or lowercase in a name field. They can put in whatever they like but
there as to be a character a-z in the string. How shall the test
expression look like?

/Lars

You mean:

/[a-zA-Z/

?

Jacob
 
J

Jacob Heider

I need to check that the user as put in at least one character between
a-z upper or lowercase in a name field. They can put in whatever they
like but there as to be a character a-z in the string. How shall the
test expression look like?

/Lars

You mean:

/[a-zA-Z/

?

Jacob

That's what I get for staying up all night. Should be (of course)

/[a-zA-Z]/
^

Jacob
 
J

John W. Krahn

Lars said:
I need to check that the user as put in at least one character between
a-z upper or lowercase in a name field. They can put in whatever they
like but there as to be a character a-z in the string. How shall the
test expression look like?


my $alpha_count = $name =~ tr/a-zA-Z//;
if ( $alpha_count >= 1 ) {

But if you really want to use a regular expression instead:

my $alpha_count = () = $name =~ /[a-zA-Z]/g;
if ( $alpha_count >= 1 ) {



John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top