140821 string, number, date and Application Example

Source: Internet
Author: User

 

Brerk completely breaks the loop and jumps out of the for statement.

Continue interrupts the current loop and performs the next loop

 

 

 

 

Length of S. length S
 
 
 
S. Trim () Remove spaces on both sides
 
S. trimstart () removes the leading space
 
S. trimend () removes Spaces
 
 
 
S. toupper () uppercase letters
 
S. tolower () letters smaller to write
 
 
 
S. substring () 1. Trash position to the last 2. (trash position, length)
 
 
 
S. startswith () determines whether the start of the string matches
 
S. endswith () determines whether the end of the string matches
 
S. Contains () Middle
 
 
 
S. indexof () position where the first appearance of the number of front faces
 
S. lastindexof () from the position where the next number appears for the first time
 
 
 
S. Replace () replace

 

 

 

 

 

Example:

// Determine whether the date is correct

Console. Write ("input year ");

Int I = convert. toint32 (console. Readline ());

Console. Write ("input month ");

Int M = convert. toint32 (console. Readline ());

Console. Write ("input date ");

Int n = convert. toint32 (console. Readline ());

 

 

 

If (I> = 1 & I <= 9999)

{

If (I % 400 = 0 | I % 4 = 0 & I % 100! = 0)

{

If (M> = 1 & M <= 12)

{

If (n> = 1 & n <= 31 & (M = 1 | M = 3 | M = 5 | M = 7 | M = 8 | M = 10 | M = 12 ))

{

Console. writeline ("the date you entered is correct ");

}

Else if (n> = 1 & n <= 30 & (M = 4 | M = 6 | M = 9 | M = 11 ))

{

Console. writeline ("the date you entered is correct ");

}

Else if (n> = 1 & n <= 29)

{

Console. writeline ("the date you entered is correct ");

}

Else

{

Console. writeline ("the value you entered is meaningless ");

}

}

Else

{

Console. writeline ("the value you entered is meaningless ");

}

 

 

}

Else

{

If (M> = 1 & M <= 12)

{

If (n> = 1 & n <= 31 & (M = 1 | M = 3 | M = 5 | M = 7 | M = 8 | M = 10 | M = 12 ))

{

Console. writeline ("the date you entered is correct ");

}

Else if (n> = 1 & n <= 30 & (M = 4 | M = 6 | M = 9 | M = 11 ))

{

Console. writeline ("the date you entered is correct ");

}

Else if (n> = 1 & n <= 28)

{

Console. writeline ("the date you entered is correct ");

}

Else

{

Console. writeline ("input error ");

}

}

Else

{

Console. writeline ("input error ");

}

}

}

Else

{

Console. writeline ("input error ");

}

 

 

 

// Specifies the date when the ID card is intercepted.

Console. writeline ("Enter your ID card number :");

String I = convert. tostring (console. Readline ());

If (I. Length = 18)

{

Console. writeline (I. substring (6, 8 ));

}

Else

{

Console. writeline ("input error ");

}

 

// Determine the email address

Console. Write ("input Email :");

String S = console. Readline ();

Bool M = S. startswith ("");

Bool n = S. startswith (".");

Int A = S. indexof ("@");

Int c = S. lastindexof ("@");

Bool B = S. Contains (".");

Bool d = S. Contains ("..");

If (M = n = d = false &! = 0 &! = C & B = true)

{

Console. writeline ("yes ");

}

Else

Console. writeline ("not ");

 

140821 string, number, date and Application Example

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.