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/01 Report--
This article mainly introduces the regular expression how to achieve reverse order look around, 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.
1 the question leads to
I encountered such a problem in the CSDN forum a few days ago.
I'm going to take out the string between the following and the following through the rules.
1. The string between and cannot be fixed, it is randomly generated automatically.
2. The number of and can not be fixed, and it is also randomly generated automatically.
* * this is an unfixed string 1 * *
* * this is an unfixed string 2 * *
* * this is an unfixed string 3 * *
A friend gives such a regular "(? a test")
String reg = "(?" The length is not fixed, so it will be searched character by character from the current position. Of course, it is also possible that the regular engine has been optimized to first calculate the minimum length and then look forward. Here "* >" requires at least 5 characters. So look for 5 characters to the left from the current position before trying to match. It depends on how the regular engines of each language are implemented. I guess the minimum length is calculated first. However, because it is at position 0 and there are no characters in front of it, the attempt to match fails.
The regular engine gearing drives to the right and tries to match from position 1, but also fails until position 5, looks for 5 characters to the left, satisfies the condition, and gives the control to "(?)" The subexpression "] * >" in "] * >" after the control is obtained, the match starts to the right at position 0. Since the rules are matched character by character, the control is handed over to the "" in "] * >" for matching, and the matching fails. At this time, there is no state to be traced back, so this round of matching attempts failed.
The regular engine gearing drives to the right and starts to try to match at position 6, and the match also fails until position 16, where the current position refers to position 16, gives control to "(?)", looks for 5 characters to the left, meets the conditions, records the backtracking status, and gives control to "(?)". The subexpression "] * >" in the. "] * >" after gaining control, try to match to the right from position 11, "in"] * > "
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.