Simple judgment of the mailbox format (some of which are not resolved) (see Supplement and hints)

Source: Internet
Author: User

Let the user enter a mailbox and verify the legality of the entered mailbox.

Notes on the legality of the mailbox:

A. There is only one "@" sign.

B. At least one "." After the "@" sign But not more than two.

C. If there are two ".", two "." Can't be together.

D. Cannot start with "@" and cannot end with "@"

E. " @ "and". " Can't be together.

F. Cannot be "." At the beginning, cannot be "." End

Console.Write ("Please enter your e-mail:");

String k = Console.ReadLine ();

int a = K.indexof ("@");

int B = K.lastindexof ("@");

int c = K.indexof (".");

int d = K.lastindexof (".");

BOOL E = K.startswith ("@");

bool F = K.startswith (".");

BOOL G = K.endswith ("@");

bool h = K.endswith (".");

if (A = = B && C > a && c + 1! = d && e = False && F = = False && G = = False &am p;& h = = False)

{

if (c! = d)

{

String L = k.substring (c + 1, d-1);

bool m = L.contains (".");

if (M = = False)

{

Console.WriteLine ("The mailbox is formatted correctly! ");

}

Else

{

Console.WriteLine ("Mailbox format is wrong! ");

}

}

Console.WriteLine ("The mailbox is formatted correctly! ");

}

Else

{

Console.WriteLine ("Mailbox format is wrong! ");

}

Simple judgment of the mailbox format (some of which are not resolved)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.