The Concept and Usage Analysis of Regular Expressions

Time:2019-5-31

This paper illustrates the concept and usage of regular expression looping. Share for your reference, as follows:

1. Looking around is also called pre-search and zero-width assertion.

2. Circumferential vision is further divided into

         (?=exp)Affirmative sequential glance

         (?<=exp)Positive Reverse Sequence Looking around

         (?!exp)Negative Sequence Looking around

         (?<exp)Negative Reverse Sequence Looking around

3. Looking around occupies only logical position, not physical position.

For example: matching files with suffix name TXT

Characters: file. txt, file2. exe rules\w(?=.exe)Match string File2

4. Usage of Looking around

(?= exp) Two uses of affirmative sequential looping

1. Finding the phone number is 132.

Character: My work number is 132. My telephone number is 13244444. My 158 is 15822222.

regular(?=\d{11})132\d{8}Matching 13244444444

Explanation: Match 132 and 158 numbers first, then match the number 2 according to the expression on the left.

(2) Find files with suffix name TXT

Character file1.txt file2.exe

regular\w+(?=.exe)Match string File2

(?<=exp) Affirms the use of reverse looping

(1) Get the file suffix of the specified file

Character file1.text file2.exe fiel3.jpg

regular(?<=[/\w]+\.)\w+Matching character text exe jpg

PS: Here are two very convenient regular expression tools for your reference.

JavaScript Regular Expressions Online Testing Tool:
http://tools.jb51.net/regex/javascript

Online Generation Tool for Regular Expressions:
http://tools.jb51.net/regex/create_reg

I hope that this paper will be helpful for regular expression learning.

Recommended Today

A detailed explanation of the differences between Perl and strawberry Perl and ActivePerl

Perl is the abbreviation of practical extraction and report language “practical report extraction language”. Application of activestateperl and strawberry PERL on Windows platformcompiler。 Perl   The relationship between the latter two is that C language and Linux system have their own GCC. The biggest difference between activestate Perl and strawberry Perl is that strawberry Perl […]