Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of regular (\ w) (? =\ 1\ 1\ 1) (\ 1) +

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shares with you the content of the sample analysis of regular (\ w) ((? =\ 1\ 1) (\ 1)) +. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Forward presearch: "(? = xxxxx)", "(?! xxxxx)"

Format: "(? = xxxxx)". In the matched string, it adds a condition to the "gap" or "both ends": the right side of the gap must be able to match the expression on this part of the xxxxx. Because it is only here as an additional condition to the gap, it does not affect the following expression to actually match the characters behind the gap. This is similar to "\ b", which does not match any characters. "\ b" only takes the characters before and after the gap to make a judgment, and will not affect the following expression to really match.

Click test example 1: when the expression "Windows (? = NT | XP)" matches "Windows 98, Windows NT, Windows 2000", only the "Windows" in "Windows NT" will be matched, and the other words "Windows" will not be matched.

Click the test example 2: expression "(\ w) ((? =\ 1\ 1\ 1) (\ 1)) +" when matching the string "aaa ffffff 999999999", it will be able to match the first four of the six "f" and the first seven of the nine "9". This expression can be interpreted as: if you repeat the alphanumeric number more than 4 times, it matches the part before the last 2 digits. Of course, this expression can not be written in this way, and the purpose here is for demonstration purposes.

Example: for example, 999999999 or 666666

1. (\ w) (? =\ 1\ 1\ 1) (\ 1) +

The last + sign means that one or more of the 666666 matches the first four sixes, while the 999999999 matches only the first seven, leaving two behind anyway.

Because (? =\ 1\ 1) is used, only two are matched at a time, but make sure there are 99 on the right, take two each time, and include the previous one each time.

(\ w) (? =\ 1\ 1\ 1) (\ 1)) + is actually matched six times in 999999999.

The first time: (\ w) take out the first 9, (? =\ 1\ 1\ 1) limit the second 9 to the fourth 9, (\ 1) take out the second 9 and get 99

The second time: (? =\ 1\ 1\ 1) limit the third 9 to the fifth 9, (\ 1) take out the third 9 and get 999

The third time: (? =\ 1\ 1\ 1) limit the fourth 9 to the sixth 9, (\ 1) take out the fourth 9 and get 9999

The fourth time: (? =\ 1\ 1\ 1) limit the fifth 9 to the seventh 9, (\ 1) take out the fifth 9 and get 99999

The fifth time: (? =\ 1\ 1\ 1) limit the 6th 9 to the 8th 9, (\ 1) take out the 6th 9 and get 999999

The sixth time: (? =\ 1\ 1\ 1) limit the seventh 9 to the ninth 9, (\ 1) take out the seventh 9 and get 9999999

2. (\ w) ((\ 1) (? =\ 1)) +

The first time\ w takes out the first 9,\ 1 takes another 9, which is 99, followed by two 9 to meet the condition. All the first time is 99.

The second time from the third 9 to the fourth 9, start with\ 1 and take another 999

The third match takes a 9999 from the 4th-6th 9s.

Take a 99999 from the fifth to the seventh nine for the fourth time.

The fifth time to take one from the sixth to eighth nine is 999999

For the sixth time, one still satisfied after the 7th-9th is 9999999.

There are no more than three 9s on the right side of the eighth start of the seventh time, all cancel the match, the seven 9s before the match.

3. (?

The concept of the two formats is similar to the forward pre-search, which requires the "left" of the gap, and the two formats must be able to match and must not be able to match the specified expression, instead of judging the right. Like forward pre-search, they are an additional condition to the gap in which they are located, and they themselves do not match any characters.

Example 5: expression "(?

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report