In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of single-line and multi-line patterns in regular expressions, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
Regular expressions are used in single-line, multi-line patterns, and are prone to errors. Single-line and multi-line patterns are all parameters that appear in the pattern modifiers of regular expressions. At present, this option is available for all commonly used regular expressions, such as: javascript regular expressions, usually "/ regular expressions match characters / modifiers", and the last "/" is followed by a modifier. Then, php is also similar, cantilever, etc., generally call regular expression matching functions, there is another option to set the mode.
Single-line and multi-line modes are prone to misunderstandings.
Why is it easy to make misunderstandings? their corresponding instructions in English are: SingleLine, MultiLine, which happens to mean single-line and multi-line. Therefore, many friends will take it literally and draw the following conclusions: (, just used, I am also one of these friends)
1. Single line, that is, match from beginning to end. Multiple lines, that is, if there is a newline character in the matching string, it matches to the front.
2. A single line conflicts with multiple lines. Only one option can be specified at a time, and cannot be used at the same time.
In fact, it is easy to understand in this way. Let's see what the official manual says.
Official explanation of single-line and multi-line model
Pattern character description s (single line) if this modifier is set, the period metacharacters in the pattern match all characters, including newline characters. Without this modifier, the dot mismatch newline character m (multiline) the target string is made up of single-line characters (although in fact it may contain multiple lines), and the "line beginning" metacharacter (^) matches only the beginning of the string. The "end of line" metacharacter ($) matches only the end of the string. When this modifier is set, "line beginning" and "line end" match any newline character (\ n) in the target string before or after
As explained above, in fact, these two modifiers only modify the matching range of common metacharacters in regular expressions. If you add the "s" modifier, metacharacter "." Will be able to match the newline character (\ n), if you add the "m" modifier, the metacharacter "$" will only match before the "\ n" character, and the metacharacter "^" will match after the "\ n" character. Let's give an example. The following is about regular expressions? Characters, you can take a look at the previous section: regular expressions (regex) greedy patterns, lazy patterns)
For example, look at the single-line application
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.