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)