0Pricing
NLP Academy · Lección

Regex en 5 minutos

Literales, clases y cuantificadores

Regex en 5 minutos es una lección gratuita de NLP Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de NLP Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de NLP Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

A Tiny Language for Patterns

A regular expression is a tiny pattern language for matching text. Instead of one fixed word, you describe the shape of what you want to find.

Python Speaks Regex Too

Python uses the built-in re module for regex. Import it once and you can search, match, and extract patterns from any string.

import re
re.search("cat", "the cat sat")

Literals: Exact Characters

The simplest pattern is a literal. The pattern dog matches the exact letters d, o, g, in that order, wherever they appear in your text.

search Finds the First Match

Use re.search to scan a string and return the first place your pattern appears, or None when nothing matches at all.

m = re.search("sat", "the cat sat")
print(m.group())

Character Classes With Brackets

A character class in square brackets matches any one listed character. The pattern [abc] matches a single a, b, or c each time.

re.findall("[aeiou]", "hello")

Handy Class Shortcuts

Some classes have shortcuts. \d matches any digit, \w matches word characters, and \s matches spaces. They save you a lot of typing. 😊

The Dot Matches Anything

The dot stands for any single character except a newline. So h.t matches hat, hit, and hot, but never the two-letter ht.

Quantifiers Repeat Patterns

A quantifier says how many times the part before it repeats. Add a plus for one or more, a star for zero or more.

re.findall("a+", "aaa banana")

Exact Counts With Braces

Use braces for precise repetition. The pattern \d{3} matches exactly three digits in a row, perfect for area codes or short IDs.

re.findall("\d{3}", "call 911 now")

Anchors Pin the Position

Anchors match a position, not a character. The caret means start of string and the dollar sign means end of string.

findall Returns Every Match

While search finds one match, re.findall returns a list of every match in the text, which is great for counting or extracting many items.

re.findall("\d+", "2 cats, 5 dogs")

Quick Check

You want to match exactly three digits in a row. Which pattern fits?

Recap: Your Regex Toolkit

You met literals, classes, the dot, quantifiers, and anchors. With re.search and re.findall, you can already describe and find real patterns. 🎉

Preguntas frecuentes

¿La lección «Regex en 5 minutos» es gratis?

Sí — el texto completo de «Regex en 5 minutos» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de NLP Academy, actualiza a CoddyKit PRO. El curso de NLP Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Regex en 5 minutos»?

Literales, clases y cuantificadores Practicas NLP Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar NLP Academy?

No se requiere experiencia previa. NLP Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.

¿Cuánto tiempo toma la lección «Regex en 5 minutos»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de NLP Academy?

Sí. Cada lección de NLP Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Regex en 5 minutos
  2. Búsqueda de correos electrónicos y URL
  3. Grupos de captura y reemplazos
  4. Trucos de tokenización con Regex
← Volver a NLP Academy