C # (5)--Regular Expression class

Source: Internet
Author: User

1. Regex

C#regex is a regular expression class
Used for string processing to find a matching string.

By further exploring the use of regular expressions, I learned the following usage:

(? = subexpression): 0 width Positive lookahead assertion. The match continues only if the subexpression matches the right side of this position. For example, 19 (? =99) matches the 19 instance that precedes 99.

(?! sub-expression): 0 width Negative lookahead assertion. The match continues only if the sub-expression does not match to the right of the position. For example, (?! 99) matches a word that does not end with 99, so it does not match 1999.

(? <= sub-expression): 0 width is being recalled after the assertion is issued. The sub-expression continues to match only if the subexpression matches the left side of this position. For example, (? <=19) 99 matches an instance of 99 followed by 19. This construct does not backtrack.

(? <! sub-expression): 0 width negative review post assertion. The match continues only if the subexpression does not match to the left of this position. For example (? <!19) matches a word that does not start with 19, so it does not match 1999.

The program implemented is:

Output Result:

2. How to get the time

The implemented method to get the current time is:

If extended to weeks, it should be:

3. Int. TryParse () and Int. The difference between Parse ():

After the output test, the experience can be collated:

Int. TryParse () and Int. Parse () can only be an integer string type (that is, after the various integer tostring () and cannot be a floating-point type

otherwise int. Parse () will appear with an incorrect string format for the input int. TryParse () also returns false with an output parameter of 0)

and (int) can only be a numeric type (example Float,int,uint, etc.);

C # (5)--Regular Expression class

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.