In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the use of a full stop 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.
First of all, we must understand it correctly. The meaning of. In fact, it may be misleading to say that it represents any single character. It must be emphasized that this "arbitrary single character" does not include characters that control line breaks, that is, it does not include\ n\ r\ u2028 or\ u2029 characters. These characters can be contained in\ W and\ s. The difference between the two ways of writing is also very clear, that is, whether it can match the difference of several newline control characters.
So when do we need to consider these newline controllers? When the string to be processed may contain line breaks. There are too many such scenarios, dealing with html strings, processing template, nodejs reading text, and so on.
When it comes to the scenario of multiline text, it is easy to think of the m mode (multiline mode) of regular expressions. Does so many line patterns have an impact on the issues we are talking about today? I'm not so sure. Why aren't you sure? Some people swear that in one-way mode. The meaning is different from that in multiline mode, which is equivalent to [\ w\ W] or [\ s\ S] in single-line mode, while newline controllers are excluded in multiline mode. But according to my experiment, and referring to MDN, this is wrong. It is true that regular expressions in many languages have these features, but I don't see them in javascript and I don't know if there will be any browser differences. So what is the impact of multiline mode on javascript? I think it just changes the meaning of the ^ and $identifiers: in single-line mode, it represents the beginning and end of the entire string, respectively; in multiline mode, it represents the beginning and end of each line. Regardless of multi-line mode or single-line mode, I think. All contain no newline control characters, which is equivalent to [^\ n\ r\ u2028\ u2029].
With a little more extension, for modern browsers, you can directly use [^] to match any character.
If you don't want to write an example program, you can try it yourself. Use /. * / g, / ^. * $/ g, /. * / gm, / ^. * $/ gm to match "abc\ nedf". The reason is self-evident.
Thank you for reading this article carefully. I hope the article "what is the use of the full stop in regular expressions" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.