PHP implementation of regular expression grouping capture steps in detail

Source: Internet
Author: User
Tags php regular expression
This time to bring you the PHP implementation of the regular expression grouping capture steps in detail, the PHP implementation of the regular expression grouping captures the attention of what, the following is the actual case, together to see.

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>

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

PHP replace article picture path to local server steps in detail

PHP's summary of source code encryption methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.