Text is everywhere in software — user input, log files, configuration values, API responses. Python’s built-inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/marioaje/Python/llms.txt
Use this file to discover all available pages before exploring further.
re module gives you a powerful toolkit for searching, splitting, and transforming text using regular expressions: concise patterns that describe exactly what you are looking for. Whether you need to validate an email address, extract dates from a document, or clean up messy data, re handles it in a single function call. Alongside text processing, dictionaries and lists of dictionaries let you store structured, JSON-like data directly in Python — a skill that becomes essential the moment you start working with real-world APIs and databases.
Section 1 — Regular Expressions with the re Module
To use regular expressions you first import the re module. The course examples in expresionesregulares.py walk through the four most common operations — search, findall, split, and sub — on a single text string.
The source code in full
Semana 2/expresionesregulares.py
Walking through each operation
Common re functions — quick reference
| Function | Signature | What it does | Returns |
|---|---|---|---|
re.search() | re.search(pattern, string) | Scans through the string and returns the first location where the pattern matches | Match object or None |
re.findall() | re.findall(pattern, string) | Finds all non-overlapping matches of the pattern | list of strings |
re.split() | re.split(pattern, string) | Splits the string at every occurrence of the pattern | list of substrings |
re.sub() | re.sub(pattern, repl, string) | Replaces every match of the pattern with repl | New string |
re.match() | re.match(pattern, string) | Like search, but only matches at the start of the string | Match object or None |
Section 2 — Dictionaries and Nested Dictionaries
A Python dictionary stores key-value pairs and is the natural way to represent a structured record — much like a JSON object.lista.py shows how to build a flat dictionary, a standalone nested dictionary, and then embed one inside the other.
Semana 2/lista.py
direccionis an ordinary flat dictionary representing an address.diccionarioJsonembedsdireccionas the value for its'Direccion'key — giving you a nested dictionary.'MyLista'shows that dictionary values can be any Python type, including lists.testresembles a typical user record you might receive from a REST API — string IDs, emails, and hashed passwords all stored as key-value pairs.
Accessing values
Section 3 — Lists and Mixed-Type Dictionary Values
Python lists can hold any type of value, including dictionaries. Thelista.py source shows this directly: mylista is a plain list of integers, and diccionarioJson embeds it as the value for the 'MyLista' key alongside strings and a nested dictionary.
Semana 2/lista.py
test dictionary in the source file models a typical user record — the kind returned by a REST API or stored in a database:
Semana 2/lista.py
Notice that all values in
test are strings, including "id" and "password". This mirrors how JSON data arrives from a REST API — even numbers are often transmitted as strings and must be converted with int() or float() before you can perform arithmetic on them.Flat dictionary
Key-value pairs at a single level. Access values with
dict['key'].Nested dictionary
A dictionary whose value is another dictionary. Access with
dict['outer']['inner'].Embedded list
A dictionary value can be a list. Access with
dict['key'] then index or iterate normally.Mixed values
Dictionary values can be strings, numbers, lists, or other dictionaries — just like JSON.