File tree 1 file changed +30
-0
lines changed
Roadmap/16 - EXPRESIONES REGULARES/python
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ /*
3
+ * EJERCICIO:
4
+ * Utilizando tu lenguaje, explora el concepto de expresiones regulares,
5
+ * creando una que sea capaz de encontrar y extraer todos los números
6
+ * de un texto.
7
+ *
8
+ * DIFICULTAD EXTRA (opcional):
9
+ * Crea 3 expresiones regulares (a tu criterio) capaces de:
10
+ * - Validar un email.
11
+ * - Validar un número de teléfono.
12
+ * - Validar una url.
13
+ */
14
+ """
15
+
16
+ import re
17
+
18
+ # EJERCICIO:
19
+ texto = 'Este es mi texto numero 123456'
20
+ busqueda = re .findall ('[0-9]' , texto )
21
+ print (busqueda )
22
+
23
+ # DIFICULTAD EXTRA:
24
+ validar_email = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
25
+ validar_telefono = '^\\ +?[1-9][0-9]{7,14}$'
26
+ validar_url = '((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z]){2,6}([a-zA-Z0-9\.\&\/\?\:@\-_=#])*'
27
+
28
+ print (
re .
fullmatch (
validar_email ,
'[email protected] ' ))
29
+ print (re .match (validar_telefono , '+543413333333' ))
30
+ print (re .match (validar_url , 'https://www.google.com' ))
You can’t perform that action at this time.
0 commit comments