In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "regular expression before and after looking for lookaround example analysis", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn the "regular expression before and after looking for lookaround example analysis" this article.
I. introduction of questions
In a HTML page, match the text between a pair of tags, such as the tag of the page, that is, the text between and:
Text: welcome to my page
Regular expression:. *?
Results: [welcome to my page]
Analysis: means case-insensitive, this pattern matches the title tags and the text between them, but not perfectly, because we only want the text between the title tags, not the tags themselves. To solve this problem, we need to use forward and backward search (lookaround).
Second, look forward
Lookup forward specifies a pattern that must match but is not returned in the result. Looking forward is actually a subexpression that starts with? =, and the matching text is followed by =.
Look at an example that matches the protocol portion of an URL address:
Text: http://blog.csdn.net/mhmyqn
Regular expression:. + (? =:)
Results: [http]: / / blog.csdn.net/mhmyqn
Analysis: the protocol part of the URL address is before:, the pattern. + matches any text, the subexpression (? =:) matches:, but what is matched: does not appear in the result. We use? = to indicate to the regular expression engine that all we have to do is find:, but it is not included in the final return result. If you don't use forward matching (? =:) here, but use (:) directly, then the result of the match will be http:, which includes:, which is not what we want.
Note: before and after the search refers to the relative position of the pattern and the searched text, the left is the front and the right is the back. That is, the forward search is: xxx (? = xxx), and the backward search is (?
Text: I paid $30 for 10 apples, 15 oranges, and 10 pears. I saved $5 onthis order.
Regular expression: (? Results: I paid $30 for [10] apples, [15] oranges, and [10] pears. I saved $5 on this order.
Analysis: (?
The above is all the content of the article "sample Analysis of finding lookaround before and after regular expressions". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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.