From 10a5a04ff4822d959a3ac0262ee2999d745d081d Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Wed, 10 Mar 2021 14:43:55 -0300 Subject: [PATCH 1/3] 9-14 lookaround tareas --- .../1-find-non-negative-integers/solution.md | 12 ++++----- .../1-find-non-negative-integers/task.md | 10 +++---- .../2-insert-after-head/solution.md | 26 +++++++++---------- .../2-insert-after-head/task.md | 12 ++++----- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md index a824409f9..b9b8c1e8e 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md @@ -1,9 +1,9 @@ -The regexp for an integer number is `pattern:\d+`. +La expresión regular para un número entero es `pattern:\d+`. -We can exclude negatives by prepending it with the negative lookahead: `pattern:(?` tag, we must first find it. We can use the regular expression pattern `pattern:` for that. +Para insertar algo después de la etiqueta ``, primero debemos encontrarla. Para ello podemos usar la expresión regular `pattern:`. -In this task we don't need to modify the `` tag. We only need to add the text after it. +En esta tarea no debemos modificar la etiqueta ``. Solamente agregar texto después de ella. -Here's how we can do it: +Veamos cómo podemos hacerlo: ```js run let str = '......'; @@ -11,9 +11,9 @@ str = str.replace(//, '$&

Hello

'); alert(str); // ...

Hello

... ``` -In the replacement string `$&` means the match itself, that is, the part of the source text that corresponds to `pattern:`. It gets replaced by itself plus `

Hello

`. +En el string de reemplazo, `$&` significa la coincidencia misma, la parte del texto original que corresponde a `pattern:`. Es reemplazada por sí misma más `

Hello

`. -An alternative is to use lookbehind: +Una alternativa es el uso de "ver detrás": ```js run let str = '......'; @@ -22,15 +22,15 @@ str = str.replace(/(?<=)/, `

Hello

`); alert(str); // ...

Hello

... ``` -As you can see, there's only lookbehind part in this regexp. +Como puedes ver, solo está presente la parte "ver detrás" en esta expresión regular. -It works like this: -- At every position in the text. -- Check if it's preceeded by `pattern:`. -- If it's so then we have the match. +Esto funciona así: +- En cada posición en el texto. +- Chequea si está precedida por `pattern:`. +- Si es así, tenemos una coincidencia. -The tag `pattern:` won't be returned. The result of this regexp is literally an empty string, but it matches only at positions preceeded by `pattern:`. +La etiqueta `pattern:` no será devuelta. El resultado de esta expresión regular es un string vacío, pero coincide solo en las posiciones precedidas por `pattern:`. -So we replaces the "empty line", preceeded by `pattern:`, with `

Hello

`. That's the insertion after ``. +Entonces reemplaza la "linea vacía", precedida por `pattern:`, con `

Hello

`. Esto es, la inserción después de ``. -P.S. Regexp flags, such as `pattern:s` and `pattern:i` can also be useful: `pattern://si`. The `pattern:s` flag makes the dot `pattern:.` match a newline character, and `pattern:i` flag makes `pattern:` also match `match:` case-insensitively. +P.S. Los indicadores de Regexp tales como `pattern:s` y `pattern:i` también nos pueden ser útiles: `pattern://si`. El indicador `pattern:s` hace que que el punto `pattern:.` coincida también con el carácter de salto de línea, y el indicador `pattern:i` hace que `pattern:` también acepte coincidencias `match:` en mayúsculas y minúsculas. diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md index be1a259f6..e442c36f8 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md @@ -1,13 +1,13 @@ -# Insert After Head +# Insertar después de la cabecera -We have a string with an HTML Document. +Tenemos un string con un documento HTML. -Write a regular expression that inserts `

Hello

` immediately after `` tag. The tag may have attributes. +Escribe una expresión regular que inserte `

Hello

` inmediatamente después de la etiqueta ``. La etiqueta puede tener atributos. -For instance: +Por ejemplo: ```js -let regexp = /your regular expression/; +let regexp = /tu expresión regular/; let str = ` @@ -20,7 +20,7 @@ let str = ` str = str.replace(regexp, `

Hello

`); ``` -After that the value of `str` should be: +Después de esto el valor de `str` debe ser: ```html

Hello

From d2f9621f58d36f1153a003be6c2e0fe088bd61d9 Mon Sep 17 00:00:00 2001 From: joaquinelio Date: Fri, 18 Jun 2021 05:38:24 -0300 Subject: [PATCH 2/3] Update solution.md --- .../1-find-non-negative-integers/solution.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md index b9b8c1e8e..0779974f0 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md @@ -1,7 +1,7 @@ La expresión regular para un número entero es `pattern:\d+`. -Podemos excluir los negativos anteponiendo un "ver detrás negativo": `pattern:(? Date: Fri, 18 Jun 2021 05:41:28 -0300 Subject: [PATCH 3/3] Update solution.md --- .../2-insert-after-head/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md index 6f7cc3c42..31e82927b 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md @@ -13,7 +13,7 @@ alert(str); // ...

Hello

... En el string de reemplazo, `$&` significa la coincidencia misma, la parte del texto original que corresponde a `pattern:`. Es reemplazada por sí misma más `

Hello

`. -Una alternativa es el uso de "ver detrás": +Una alternativa es el uso de "lookbehind": ```js run let str = '......'; @@ -22,7 +22,7 @@ str = str.replace(/(?<=)/, `

Hello

`); alert(str); // ...

Hello

... ``` -Como puedes ver, solo está presente la parte "ver detrás" en esta expresión regular. +Como puedes ver, solo está presente la parte "lookbehind" en esta expresión regular. Esto funciona así: - En cada posición en el texto. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy