in reply to Re: About validating mail id
in thread About validating mail id

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: About validating mail id
by Corion (Patriarch) on Feb 03, 2010 at 12:24 UTC

    Do you want to make sure that the string does not contain .com.com or do you want to make sure that the string does not contain .com twice? See index and rindex:

    for my $mail (qw( bar@foo.com.com bar@foo.computers.com bar@com.computers.com bar@b.com.computers.org)) { print "Looking at '$mail'\n"; printf "index '.com': %d\n", index '.com', $mail; printf "index '.com.com': %d\n", index '.com.com', $mail; printf "rindex '.com': %d\n", rindex '.com', $mail; }

    You could also create a regular expression that has a lookahead component, but as your problem is not well-defined, I won't write it.

Re^3: About validating mail id
by Ratazong (Monsignor) on Feb 03, 2010 at 12:24 UTC
    see here (perlfaq4): Just count (additionally) how often .com occurs in your string
    However this is probably not what you want ... you probably want to allow a@my.company.com ... so you might want to search for .com.com ... or even   \.com\.com$