En el🧵de hoy, te voy a enseñar algunas expresiones regulares simples para que puedas empezar a usarlas ya. Ahorrán mucho tiempo, y dominar algunas te ayudará.
No para posicionar, pero para trabajar de manera más eficiente.
🤷♂️¿Que son las expresiones regulares (REGEX)? 🤷♂️
Sirven para describir cadenas de texto, números y caracteres especiales con el fin de buscarlas o manipularlas.
Se pueden usar en la gran mayoría de las herramientas, como por ejemplo Sheets:
Las REGEX pueden asustar, pero te voy a detallar cuáles son las más comunes y qué hacen.
Usaré regex101.com en mi pantallazos, que te permite validar tus REGEX de manera sencilla.
1. Punto (.)
Representa cualquier carácter.
2. Estrella (*)
Indica que el elemento al que sigue se puede repetir 0 o más veces. Si lo combinamos con el punto, significa "cualquier cadena".
Similar: el más (+) que indica 1 o más veces.
3. Barra vertical (|)
Significa OR. Permite indicar varios valores que puedes estar buscando.
En mis ejemplo, ves que la segunda opción no coincide con mi REGEX porque la extensión (co.uk) no está dentro de mis opciones.
4. Barra invetida (\)
Permite "escapar" un carácter para que se interprete literalmente (no con su significado REGEX).
En mi ejemplo, escapo el punto: quiero un punto sí o sí.
5. Signo de interrogación (?)
Indica que el elemento al que sigue es opcional.
En mi ejemplo, la barra final es opcional, por lo tanto mi REGEX coincide tanto con el primer texto como el tercero.
6. Barra invertida + d (\d)
Indica un carácter númerico.
Si lo combiamos con +, indicamos que queremos una cadena de 1 o varios dígitos.
7. [a-z]
Indica una letra (minúscula).
* si quieremos una letra mayúscula, tenemos que usar [A-Z]
* si queremos una letra mayúscula o minúscula, tenemos que usar [a-zA-Z]
8. {número}
Indica que el elemento al que sigue se repite X veces.
Por ejemplo, si buscamos una URL con 3 números:
** Caso práctico **
Aplicamos todo lo que acabamos de aprender. Tengo tres URLs y quiero capturar los dígitos situado al final de las URLs, si se trata del blog.
No puedo usar \d+ porque capturaría también el número si el contenido no pertenece al blog 🤔
Si modificamos un poco nuestra REGEX, podemos capturar lo que nos interesa.
.* : lo que sea
liligo\.(fr|es): liligo.fr o liligo.es
\/blog\/: carpeta blog
[a-z-]+: palabras separadas por un -
(\d+)\: lo que queremos (por eso usamos paréntesis)
¿Te parece complicado?
Es normal, al inicio aprender las REGEX cuesta . Usa regex101.com para practicar y irás mejorando poco a poco.
Y podrás trabajar de manera más eficiente ⚡️
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Let's go through the most common formulas you need to master to work quicker.
Most of them can also be used in Excel, but not all of them.
1. VLOOKUP
THE formula you have to master because it allows you to merge data from different tables. Very useful to combine Search Console and Analytics data, for instance.
You have to master it.
2. FILTER
I've explained everything about this formula in a separate thread:
🕵️ How can you spy on a competitor's content strategy? 🕵️
Your strategy must never be a simple pale copy of what others are doing, but it's always a good idea to know what they are up to.
Let me show you, with a real example, how you can generate insights quickly.
Let's assume we're working in the travel industry and one of our competitors is Skyscanner.
We want to understand what they are doing on their blog and generate some insights based on the data we have at our disposal.
First step: get an exhaustive list of their URLs
This could be done through a crawl, but I'd rather get the list from a sitemap. Not always doable, but in this case, it was easy to find what I was looking for.
Content rehydration is a process that occurs when a website, built with a JavaScript framework, such as Angular or React, dynamically updates the content on a page without requiring a full-page refresh.
Why using rehydration instead of relying only on SSR? It is faster!
What is the issue with content rehydration?
It will add a script to the raw response sent by your server with all the required code to make the application dynamic. Out-of-the-box, this script can easily represent more than 90% of the total HTML size.