mardi 4 janvier 2022

How to find specific pattern in a paragraph in Python?

I want to find a specific pattern in a paragraph. The pattern must contain a-zA-Z and 0-9 and length is 5 or more than 5. How to implement it on Python?

My code is:

str = "I love5 verye mu765ch"
print(re.findall('(?=.*[0-9])(?=.*[a-zA-Z]{5,})',str))

this will return a null.

Expected result like:

love5
mu765ch

the valid pattern is like:

9aacbe
aver23893dk
asdf897

Aucun commentaire:

Enregistrer un commentaire