There are several quantifiers in python regular expressions
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!