Get the App
SLTechnology News&Howtos  ›  Development  › 

There are several quantifiers in python regular expressions

Shulou Source: shulou.com Published: 2022-06-03 17:36:28 10月30日 Update

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!

Tags: Quantifiers articles rules expressions laziness greed characters as much as possible value interest at the same time most examples more friends knowledge editing industry computers language Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS OPPO Reno MariaDB Redmi NVidia