File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Roadmap/16 - EXPRESIONES REGULARES/python Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import re
2+
3+ #Ejercicio
4+
5+ regex = r"\d+"
6+
7+ text = "Este es el ejercicio 16 a fecha del 22 de enero de 2025."
8+
9+ def find_numbers (text :str ) -> list :
10+ return re .findall (regex , text )
11+
12+ print (find_numbers (text ))
13+
14+
15+ #EJERCICIO EXTRA
16+
17+ def validate_email (email : str ) -> bool :
18+ return bool (re .match (r"^[\w.+-]+@[\w]+\.[a-zA-Z]+$" , email ))
19+
20+
21+ print (validate_email ("qwert@sdf.com" ))
22+
23+
24+ def validate_phone (phone : str ) -> bool :
25+ return bool (re .match (r"^\+?[\d\s]{3,}$" , phone ))
26+
27+
28+ print (validate_phone ("+34 901 65 89 044" ))
29+
30+
31+ def validate_url (url : str ) -> bool :
32+ return bool (re .match (r"^http[s]?://(www.)?[\w]+\.[a-zA-Z]{2,}$" , url ))
33+
34+
35+ print (validate_url ("http://www.moure.dev" ))
You can’t perform that action at this time.
0 commit comments