Regular Expression learning instance and regular expression instance

Source: Internet
Author: User

Regular Expression learning instance and regular expression instance

Example 1:

Regular :(? <= (Href | src | filepath) =) \ S +? (\. Jpg | \. JPG)

Resolution: The expression is divided into three sections.

Section 1:

(? <= (Href | src | filepath) =) the starting position of the query indicates that the match starts from the starting position of href =, src =, and filepath =.

Use the regular expression (? <=Pattern). If no, the match starts from this character.

Section 2:

\ S +? The configuration character in the middle. Note? Indicates the minimum match, that is, the first match in the future.

Section 3:

(\. Jpg | \. JPG.

 

This expression can be used to obtain the address after href, src, or filepath.

For example,

Match result as http://avatar.csdn.net/8/3/2/1_xanxus46.jpg

 

Example 2

Regular: (.) \ 1 (.) \ 2

Expressions Used

\ Num matches num, where num is a positive integer. References to the obtained matching. For example, "(.) \ 1" matches two consecutive identical characters. Resolution: match two (identical) repeated characters. For example, the htttpp matching result ttpp (different) The httttpp matching result is tttt (Same)

 


 

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.