This article mainly introduces the implementation of the regular expression grouping capture operation in PHP, and analyzes the relevant implementation methods of the PHP regular expression acquisition and the use of the packet capture operation with the example form, and the need of friends can refer to the following
In this paper, we describe the implementation of regular expression grouping capture operation in PHP. Share to everyone for your reference, as follows:
After testing, it was found that the PHP regular expression gets the packet capture starting from $ A, while the regular work in JavaScript is $1..$9
When extracting Chinese characters from the project code, I was worried that the operation was very fast (in a hurry). The numeric order of the properties file {\d} was mistaken:
1, may start from {1} , instead of starting with {0}
2, may jump write, such as the first {0} the second need to replace the place is written {2}
Because manual operation is used manually, this situation is unavoidable and can only be said to reduce misoperation. Finished, you have to check again, this encounter difficulties, two thousand or three thousand lines of code, with the eyes of a row, that the more tired, and not necessarily can be checked out. More prone to error, and the line between the line is too close, the word is too small ...
Suddenly remembered, think PHP can save a little time, read the file, and then the key place red ...
Then it begins: Php reads the file, then reads it line by row, uses the regular expression to match {\d} rows, and then places {\d} with a red-focused mark, and then manually goes to see if each row is eligible for the rule. The code is wrong, but it's good, at least save the time to check with your eyes:
Such a glance swept past, it can be very clear that each line of the order is written correctly, the wrong line, the front row number, find the corresponding line and then change.
<! Doctype html>
Related issues Reference article:
The correct way to read files in PHP
Mastering Regular Expressions in PHP (1)
Mastering Regular Expressions in PHP (2)
PS: Here we will provide you with 2 very convenient regular expression tool for everyone to refer to the use:
JavaScript Regular expression online test tool:
Http://tools.jb51.net/regex/javascript
The regular expression online generation tool:
Http://tools.jb51.net/regex/create_reg
Articles you may be interested in:
PHP implementation of QQ login principle and implementation process PHP instance
Automatic loading PHP Example of PHP file
PHP tips for using PHP mb_strpos