Home > Web Front-end > JS Tutorial > body text

Detailed explanation of regular expression statement annotation steps

php中世界最好的语言
Release: 2018-05-25 10:09:31
Original
1916 people have browsed it

This time I will bring you regular expressiondetailed explanation of the statement annotation steps, what are the notes for regular expression statement annotation, the following is a practical case, let’s take a look.

Another use of parentheses is to include comments via the syntax (?#comment).

For example: 2[0-4]\d(?#200-249)|25[0-5](?#250-255)|[01]?\d\d? (?#0-199).

If you want to include comments, it is best to enable the "Ignore whitespace characters in pattern" option, so that you can add spaces, tabs, and newlines arbitrarily when writing expressions, but these will be ignored when actually used. . When this option is enabled, all text following # to the end of the line will be ignored as comments. For example, we can write the previous expression like this:

(?<= # Assert the prefix of the text to be matched
<(\w )> # Find the letters enclosed by angle brackets or numbers (i.e. HTML/XML tags)
) # End of prefix
.* # Match any text
(?= # Assert the suffix of the text to be matched
<\/\1> # Find the content enclosed in angle brackets: preceded by a "/", followed by the previously captured tag

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading

Sharing of techniques for using CSS in actual combat

##Using front-end methods to convert images into character paintings

The above is the detailed content of Detailed explanation of regular expression statement annotation steps. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template