Hello, my name is Audrey and I have been a huge fan of this board during my time in college. But nonetheless, I have stumbled onto a big problem with my PERL (Regex) code. This is what I have so far:
#!/usr/bin/perl use strict; use CGI qw(:standard); #n +otifies that CGI will be implemented. print header, start_html("Form"), #start of HTML. h1("Form"); if (param()) { #variable definitions. my $who = param("firstname"); my $who2 = param("lastname"); my $email = param("email"); my $profession = param("profession"); my $creditcard = param("creditcard"); my $creditcardnumber = param("creditcardnumber"); my $question = param("question"); print p("Thank You. Here is your receipt:"); print p("Name: $who $who2"); print p("E- mail: $email"); print p("Profession: $profession"); print p("Credit Card: $creditcard"); print p("Credit Card Number: $creditcardnumber"); print p("Question: $question"); } else { print hr(), start_form(); print p("What's your first name?", textfield("firstname")); print p("What's your last name?", textfield("lastname")); print p("Enter your e- mail address", textfield("email")); print p("What is your profession?", popup_menu("profession", ['Pim +pin', 'Hustlin n Bustlin', 'Crackalakin', 'Playa', 'Thuggin n Buggin' +])); print p("What type of credit card will you be using?", radio_group +("creditcard", ['Asiv', 'Retsam Card', 'Gotham Express'])); print p("Please enter your credit card number:", textfield("credit +cardnumber")); print p("Choose a question:", checkbox_group("question", ['Do you +understand the words coming out of my mouth?', 'Go ahead, want to mak +e my day, punk?', 'Are you ready to get funkafied?'])); print p(submit("Submit"), reset("Reset")); print end_form(), hr(); } print end_html
Now, I need to know how to implement regular expressions (regex) into making the first and last names containing only alphabetical characters. Secondly, the email address must be valid, in that the input should contain an "@" sign. Thirdly, the credit card number should only contain 16 characters. If the user does not satisfy these requirements, they should be prompted back to a resetted page. I know I asking for a lot, but I really hope you guys can help.

Love always,
Audrey

Edit by tye, title, preserve formatting, etc.


In reply to Need help with regexes to validate user input by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.