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

There are several quantifiers in python regular expressions

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces python regular expression quantifier has several kinds, has a certain reference value, interested friends can refer to, I hope you read this article after a lot of gains, the following let Xiaobian with everyone to understand.

1. Quantifiers can also be subdivided into greedy quantifiers and lazy quantifiers.

Greedy quantifiers match as many characters as possible, lazy quantifiers match as few characters as possible. Most regular expression quantifiers in computer languages are greedy by default, and you want to use lazy quantifiers to add? That's it.

examples

import re m = re.search(r'\d{5,8}', '87654321')print(m) m = re.search(r'\d{5,8}? ', '87654321')print(m)

output

Thank you for reading this article carefully. I hope that Xiaobian's shared article "There are several quantifiers in python regular expressions" is helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant 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: 232

*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

Development

Wechat

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

12
Report