In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-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 regular expression m modifier how to use, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
Regular expression m modifier:
The m modifier specifies that regular expressions can perform multiline matching.
The m modifier modifies the role of ^ and $in regular expressions so that they represent the beginning and end of a line, respectively.
By default, whether or not a string wraps a line with only one beginning ^ and ending $, if multiple line matching is used, each line has a ^ and ending $.
Grammatical structure:
Constructor mode:
New RegExp ("regexp", "m")
Object direct quantity method:
/ regexp/m
Browsers support:
IE browsers support this metacharacter.
Firefox browser supports this metacharacter.
Google browser supports this metacharacter.
Example code:
Example 1:
Var str= "This is an\ n antzone good"; var reg=/an$/;console.log (str.match (reg))
The above code does not match the string "an". Although there is a line break after "an", it does not use multi-line matching, so it is not the end of the character series.
Example 2:
Var str= "This is an\ n antzone good"; var reg=/an$/m;console.log (str.match (reg))
The above code matches the string "an" because it uses multiple lines of matching.
Example 3:
Var reg = / ^ bBank str var str = 'test\ nbbs';execReg (reg,str)
The match failed because there is no b character at the beginning of the string. But after adding the m modifier:
Example 4:
Var reg = / ^ bBank str var str = 'test\ nbbs';execReg (reg,str)
Match to b, because with the m modifier added, ^ already represents the beginning of the line, and because bbs is at the beginning of the second line of the string, it can be matched successfully.
Thank you for reading this article carefully. I hope the article "how to use the regular expression m modifier" shared by the editor will be helpful to everyone. 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.