In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 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 question mark what is the use, the article is very detailed, has a certain reference value, interested friends must read it!
Original text symbol
Because? There is a special meaning in regular expressions, so if you want to match? Itself, it needs to be escaped.
With or without quantifier
The question mark can indicate that the previous content is repeated 0 times or once, that is, it either does not appear or occurs once.
Non-greedy matching
Greedy matching
When a match is satisfied, match the string as long as possible. By default, greedy matching is used.
String pattern1 = @ "a.progresc"; / / greedy match Regex regex = new Regex (pattern1); regex.Match ("abcabc"); / / return "abcabc"
Non-greedy matching
When satisfying the match, match the string as short as possible, using? To represent non-greedy matching
String pattern1 = @ "a.roomroomc"; / / non-greedy match Regex regex = new Regex (pattern1); regex.Match ("abcabc"); / / return "abc"
Several commonly used non-greedy matching Pattern
*? Repeat any number of times, but repeat as little as possible
+? Repeat one or more times, but repeat as little as possible
?? Repeat 0 or 1 times, but repeat as little as possible
{n,m}? Repeat n to m times, but repeat as little as possible
{n,}? Repeat more than n times, but repeat as little as possible
Do not snap mode
How do I turn off the ability to capture parentheses? Instead, you just use it for grouping by adding:? after the left parenthesis, where the first parenthesis is only used for grouping and does not occupy captured variables, so the content of $1 can only be steak or burger, but can never be bronto.
While () {if (/ (?: bronto) (steak | burger) /) {print "Fred wants a $1\ n";}} above is all the content of the article "what's the use of regular expression question marks". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.