Aaron Reist wrote:

From: "John W. Krahn" <[EMAIL PROTECTED]>

Aaron Reist wrote:

Currently I have a simple program takes a username from a html textbox and checks against a list of values in a notepad document. If the name is found the user is given access, if not they are prompted to try again.
What I am trying to do now is have the program check the username format BEFORE it checks against the list.
The program will check for two types of usernames - the first is #xxxxxxx# (9 alphanumeric characters. beginning and ending with a number)....the second is XxxxxxxxxxX (11 alphanumeric charactors, the first and last character in this case will always be a letter) When this second format is encounterd the program must remove the leading and ending letters and leave me with the 9 characters in the center.


is this somthing I should use the split function for?

any suggestions or examples would be greatly appreatiated.

You could use a regular expression to do that.

my $input = get_input_from_user();

$input =~ /\A(?:[[:alpha:]]([[:alnum:]]{9})[[:alpha:]]|(\d[[:alnum:]]{7}\d))\z/
and my $username = $+;

> The code you provided looks great, unfortunatly my knowledge of regular
> expressions is limited.
>
> Do you know of any webpages or tutorials that would help me construct
> regular expressions like the one you provided?

The best tutorial is this book:

http://www.oreilly.com/catalog/regex2/


Perl also includes four documents on regular expressions:

perldoc perlrequick
perldoc perlretut
perldoc perlre
perldoc perlreref

Also available on the web at:

http://perlpod.com/5.8.4/pod/perlrequick.html
http://perlpod.com/5.8.4/pod/perlretut.html
http://perlpod.com/5.8.4/pod/perlre.html
http://perlpod.com/5.8.4/pod/perlreref.html



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to