Home > Article > Web Front-end > Regular expressions look around concepts and usage_regular expressions
This article mainly introduces regular expressionsthe concept and usage of lookaround. It specifically analyzes the concept, classification, usage and related notes of lookaround. Friends in need can refer to it. Next
The examples in this article describe the concept and usage of regular expression look-around. Share it with everyone for your reference, the details are as follows:
1. Look around is also called pre-search and zero-width assertion
2. Look around is divided into
<=exp)Definitely look around in reverse order
Characters: file.txt, file2.exe Regular
\w(?=.exe)
string file2
4. How to use look around(?=exp) Two ways to use look around in certain order
Characters: My job number is my phone number starting with 132 is 13244444444, my phone number starting with 158 is 15822222222regular
(?=\d{11})132 \d{8}Matches 13244444444 Detailed explanation: First match the 132 and 158 numbers, and then match the 2 numbers according to the expression on the left
② Find the suffix name as txt file
\w+(?=.exe) matches the string file2
(?<=exp) Determine the usage of reverse lookup
① Get the file suffix character of the specified file file1.text file2.exe fiel3.jpg Regular
(?<=[/\w]+\.)\w+
PS: Here are 2 more special Convenient regular expression tool for your reference:
JavaScript
http://tools.jb51.net/regex/javascript
Regular expression online generation tool: http://tools.jb51 .net/regex/create_reg
The above is the detailed content of Regular expressions look around concepts and usage_regular expressions. For more information, please follow other related articles on the PHP Chinese website!