This article describes the concept and usage of regular expressions. Share it for your reference, as follows:
1. Surrounding is also called pre-search and zero-width assertion
2. Surrounding the eyes are divided into
(?=exp)
A positive order of circumcision
(?<=exp)
Affirmative reverse order circular viewing
(?!exp)
Negative order around view
(?<exp)
Negative reverse order circular viewing
3. Surrounding only occupies logical position and not physical position
For example: match a file with the suffix name txt
Character:, regular\w(?=.exe)
Match string file2
4. Usage of surround view
(?=exp) 2 uses of positive order surround viewing
① Find phone numbers with phone numbers starting from 132
Character: My work number is my phone number that starts with 132 is 13244444444 My phone number that starts with 158 is 158222222222
Regular(?=\d{11})132\d{8}
Match 132444444444
Detailed explanation: First match 132 and 158 numbers. Then match the 2 numbers according to the expression on the left.
② Find a file with the suffix name txt
Characters
Regular\w+(?=.exe)
Match string file2
(?<=exp)The usage of affirmative reverse order surround viewing
① Obtain the file suffix of the specified file
Characters
Regular(?<=[/\w]+\.)\w+
Match characters text exe jpg
PS: Here are two very convenient regular expression tools for your reference:
JavaScript regular expression online testing tool:
http://tools./regex/javascript
Regular expression online generation tool:
http://tools./regex/create_reg
I hope this article will be helpful to everyone's regular expression learning.