Perl compatible Regular Expressions

Sivakatirswami katir at hindu.org
Sun Mar 17 22:25:00 EST 2002


on 3/17/02 5:43 AM, metacard-request at lists.runrev.com at
metacard-request at lists.runrev.com wrote:

> What's this do? How would we use Perl in our scripts? Can anyone give an
> example of when this feature would be handy?
 Yes, one very important example is email verification:
Previously it was not so easy to do this in MC, presumably, now it will
accept these PERL expressions, my current email verifier was given by
someone else and required much more code and was still incomplete...
allowing some invalid email addresses to get through.:

## From the "famed" formMail.pl

sub check_email {
# If the e-mail address contains:                                        #
    if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
        # the e-mail address contains an invalid syntax.  Or, if the
        # syntax does not match the following regular expression pattern
# it fails basic syntax verification.                                #

        $email !~ 
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {

And this important plug:

# If they try to include server side includes, erase them, so they
        # aren't a security risk if the html gets returned.  Another
        # security hole plugged up.
        $value =~ s/<!--(.|\n)*-->//g;

Haven't tested yet...

Hinduism Today

Sivakatirswami (an ant in a world of regex elephants)
Editor's Assistant/Production Manager





More information about the metacard mailing list