Ejercicios resueltos Expresiones Regulares

Las Expresiones Regulares son muy útiles, pero complejas en determinadas situaciones. En el presente artículo os iniciaré para que entendáis de una forma sencilla su complejidad. Son ejercicios de iniciación, si el artículo tiene éxito lo completaré con Expresiones Regulares más complejas.

Las Expresiones Regulares se usan como en el ejemplo de más abajo, cuando nos piden crear un campo de tipo text que envíe una contraseña por post. La contraseña debe contener al menos entre 6 y 12 caracteres o números, o bien debe ser alfanumérica.

Expresiones Regulares

<form action="" method="post">
<input type="text" name="usuario" id="usuario" placeholder="Introduce entre 6 y 12 caracteres" 
pattern="[A-Za-z0-9]{6,12}" required></input>
<input type="submit" value="Enviar">
</form>

Como podéis comprobar aparece pattern, sería para realizar expresiones regulares.

  • [A-Za-z0-9]  –> aceptaría de la A a la Z, de la a a la z y del 0 al 9
  • {6,12} –> solamente aceptaría entre 6 y 12 valores

Ejercicio 1

pe Cadena ‘pe’

  1. PERRO (NO COINCIDE)
  2. perro (COINCIDE)
  3. pepe (COINCIDE)
  4. lep (NO COINCIDE)

Ejercicio 2

[ABC]{1} Letra mayúscula entre la A y la C (es decir, A o B o C)

  1. A (COINCIDE)
  2. Z (NO COINCIDE)
  3. casa (NO COINCIDE)
  4. CASA (NO COINCIDE)

Ejercicio 3

[A-C]{1} Una letra mayúscula entre la A y la C (es decir, A o B o C)

  1. A (COINCIDE)
  2. Z (NO COINCIDE)
  3. Casa (NO COINCIDE)
  4. LOTO (NO COINCIDE)

Ejercicio 4

[ABCabc]{1} Una letra entre la A y la C (mayúscula o minúscula)

  1. C (COINCIDE)
  2. e (NO COINCIDE)
  3. pero (NO COINCIDE)
  4. Luisa (NO COINCIDE)

Ejercicio 5

[0-9]{3} Tres dígitos numéricos

  1. 331 (COINCIDE)
  2. 112 (COINCIDE)
  3. 1233 (COINCIDE)
  4. 90 (NO COINCIDE)

Ejercicio 6

d{3} Tres dígitos numéricos

  1. 331 (COINCIDE)
  2. 112 (COINCIDE)
  3. 12a33 (NO COINCIDE)
  4. 112a33 (COINCIDE)

Ejercicio 7

d*a Ninguno, uno o más dígitos numéricos seguidos de una a

  1. 331a (COINCIDE)
  2. 112 (NO COINCIDE)
  3. 12a33 (COINCIDE)
  4. a (COINCIDE)
  5. a112 (COINCIDE)

Ejercicio 8

^a Empieza por una a

  1. 331a (NO COINCIDE)
  2. 112 (NO COINCIDE)
  3. 12a33 (NO COINCIDE)
  4. A (COINCIDE)

Ejercicio 9

a$ Acaba por una a

  1. 331a (COINCIDE)
  2. a112 (NO COINCIDE)
  3. 12a33 (NO COINCIDE)
  4. a (COINCIDE)

Ejercicio 10

[^a] Cualquier carácter que no sea una a

  1. 1aaa (COINCIDE)
  2. aaa (NO COINCIDE)
  3. 12a33 (COINCIDE)
  4. a (NO COINCIDE)

Ejercicio 11

.[abcd] Cualquier carácter seguido de una a o b o c o d

  1. 1aaa (COINCIDE)
  2. aaa1 (COINCIDE)
  3. 1233 (NO COINCIDE)
  4. a (NO COINCIDE)

Deja un comentario

slot gacor

slot gacor

https://badudu.org/

badudu

slot gacor

https://siakad.unikamamuju.ac.id/fonts/-/starlight-princess/

slot88

slot gacor

https://ninjajago.sbs/

https://labskill.umtas.ac.id/wp-content/slot-gacor/

https://kamalinews.co.id/wp-content/slot-deposit-qris/

https://lsgi.org/

https://lsgi.org/

ninjajago

slot777

slot88

http://upforfifty.xyz/

slot gacor

slot gacor

slot88

slot

https://katalog.uinsyahada.ac.id/slot/

situs slot gacor 2023

slot gacor

slot

https://게이코슬롯.com/

gacor88

slot gacor

slot thailand

slot demo

slot gacor

slot gacor

https://siakad.poltekbangmedan.ac.id/images/

slot gacor

slot gacor 4d

slot gacor

situs slot gacor

slot gacor

situs slot gacor

https://setda.blorakab.go.id/packages/upload/galeri/

slot demo

rtp slot

slot gacor

slot88

slot gacor

https://plti.amikompurwokerto.ac.id/wp-content/pages/?tunnel=Slot%20Tongkat%20123

slot88

slot-gacor

slot gacor

slot gacor

slot gacor

slot gacor

slot gacor

slot gacor

slot demo

slot88/

https://smartvillage.tubankab.go.id/vendor/

https://manajemen.unik-kediri.ac.id/wp-content/files/-/slot-toto/

https://myexist.muallimaat.sch.id/.well-known/

slot gacor

toto macau

slot gacor

slot gacor

slot gacor hari ini

slot-gacor

slot gacor

http://student.unisbank.ac.id/wp-includes/slot-gacor-hari-ini/

https://keclasem.rembangkab.go.id/error/

https://ak.polnep.ac.id/slot-gacor/

slot thailand

https://pmbtest.akpergshwng.ac.id/data/slot-qris-gacor/

slot gacor 4d

https://elsa.polteksahid.ac.id/elsa/files/slot-gacor-thailand/

https://ppdb.smai-soedirman-kotabekasi.sch.id/assets/

slot-gacor

slot-gacor

olxtoto

slot gacor

slot88

slot gacor

slot gacor

https://roadpowersystems.com/pages/

https://disdikbud.pemkomedan.go.id/assets/css/

slot4d

slot gacor

slot gacor

slot gacor

slot thailand

togel online

slot88

https://diafrica.org/pages/

togel online

slot gacor

https://fkomputer.umku.ac.id/wp-content/plugins/

slot gacor

slot gacor

slot gacor

https://feb.umku.ac.id/wp-includes/

https://fgizi.umku.ac.id/wp-content/languages/

https://fmipa.umku.ac.id/wp-includes/

slot gacor

slot88

slot88

slot gacor

slot gacor

slot gacor

slot gacor

https://fkip.umku.ac.id/wp-content/uploads/

https://fkesehatan.umku.ac.id/wp-content/plugins/

slot gacor

https://fst.umku.ac.id/wp-content/plugins/

https://fkeperawatan.umku.ac.id/wp-content/plugins/

olx toto

https://akparjakarta.ac.id/wp-content/

slot qris

slot qris

slot gacor

slot gacor

slot gopay

slot gacor

https://siakad.poltekbangmedan.ac.id/images/

slot thailand

slot gacor

slot gopay

https://ppdb.smai-soedirman-kotabekasi.sch.id/assets/

https://pmbtest.akpergshwng.ac.id/data/slot-qris-gacor/

https://cbt.dindikbud.pekalongankab.go.id/assets/

slot ovo

https://jdih.pn-labuanbajo.go.id/images/

https://pn-labuanbajo.go.id/wp-content/uploads/

https://fst.umku.ac.id/wp-content/uploads/

slot gacor

slot88

slot gacor

slot gacor

slot gacor

slot88

slot gacor

https://smkpelitanusantara.sch.id/

https://wibs.sch.id/

https://mnis.sch.id/

https://smkm3-alkamal.sch.id/

https://pelitanusantara.sch.id/

slot hoki

slot gacor kamboja

slot777

slot gacor 4d

http://esptpd.kaimanakab.go.id/public/img/

slot gacor

slot gacor

slot server luar

slot gacor

slot demo

slot88

slot hoki

https://api.kelastryout.id/assets/

https://siasuh.poltekbangmedan.ac.id/pedoman/ninjajago/

slot gacor

slot gacor

slot