Home > Article > Web Front-end > Detailed explanation of regular expression statement annotation steps
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!