- Notifications
You must be signed in to change notification settings - Fork230
Greedy and lazy quantifiers#355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
joaquinelio merged 10 commits intojavascript-tutorial:masterfromcortizg:es.javascript.info.9-10-glqAug 30, 2020
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
10 commits Select commitHold shift + click to select a range
b88371c
traducción 9-10-glq
cortizgb93e3da
Update 9-regular-expressions/10-regexp-greedy-and-lazy/article.md
cortizg4f36e0c
Update 9-regular-expressions/10-regexp-greedy-and-lazy/article.md
cortizge1987f3
Update 9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-ta…
cortizg4b80bdc
Update 9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-ta…
cortizga077326
Update 9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-ta…
cortizg920e596
Update 9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-ta…
cortizgf4883c3
Update 9-regular-expressions/10-regexp-greedy-and-lazy/article.md
cortizg4b5b44d
Update 9-regular-expressions/10-regexp-greedy-and-lazy/article.md
cortizgfb7a0c4
Update 9-regular-expressions/10-regexp-greedy-and-lazy/article.md
cortizgFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 3 additions & 3 deletions9-regular-expressions/10-regexp-greedy-and-lazy/1-lazy-greedy/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
El resultado es: `match:123 4`. | ||
Primero el perezoso `pattern:\d+?`trata de tomar la menor cantidad de dígitos posible, pero tiene que llegar al espacio, por lo que toma `match:123`. | ||
Después el segundo `\d+?`toma solo un dígito, porque es sufuciente. |
4 changes: 2 additions & 2 deletions9-regular-expressions/10-regexp-greedy-and-lazy/1-lazy-greedy/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Una coincidencia para /d+? d+?/ | ||
¿Cual es la coincidencia aquí? | ||
```js | ||
"123 456".match(/\d+? \d+?/g) ); // ? | ||
12 changes: 6 additions & 6 deletions9-regular-expressions/10-regexp-greedy-and-lazy/3-find-html-comments/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
Necesitamos encontrar el inicio del comentario`match:<!--`,después todo hasta el fin de `match:-->`. | ||
Una variante aceptable es `pattern:<!--.*?-->` --el cuantificador perezoso detiene el punto justo antes de `match:-->`.También necesitamos agregar la bandera`pattern:s`al punto para incluir líneas nuevas. | ||
De lo contrario, no se encontrarán comentarios multilínea: | ||
```js run | ||
let regexp = /<!--.*?-->/gs; | ||
let str = `... <!--Mi --comentario | ||
prueba --> .. <!----> .. | ||
`; | ||
alert( str.match(regexp) ); // '<!--Mi --comentario \nprueba -->', '<!---->' | ||
``` |
10 changes: 5 additions & 5 deletions9-regular-expressions/10-regexp-greedy-and-lazy/3-find-html-comments/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#Encuentra el comentario HTML | ||
Encuentra todos los comentarios HTML en el texto: | ||
```js | ||
let regexp = /your regexp/g; | ||
let str = `... <!--Mi --comentario | ||
prueba --> .. <!----> .. | ||
`; | ||
alert( str.match(regexp) ); // '<!--Mi --comentario \nprueba -->', '<!---->' | ||
``` |
6 changes: 3 additions & 3 deletions...-expressions/10-regexp-greedy-and-lazy/4-find-html-tags-greedy-lazy/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
La solución es `pattern:<[^<>]+>`. | ||
```js run | ||
let regexp = /<[^<>]+>/g; | ||
let str = '<> <a href="/"> <input type="radio" checked> <b>'; | ||
alert( str.match(regexp) ); // '<a href="/">', '<input type="radio" checked>', '<b>' | ||
``` |
14 changes: 7 additions & 7 deletions...ular-expressions/10-regexp-greedy-and-lazy/4-find-html-tags-greedy-lazy/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#Encontrar las etiquetas HTML | ||
Crear una expresiónregularpara encontrar todas las etiquetas HTML (de apertura y cierre) con sus atributos. | ||
Un ejemplo de uso: | ||
```js run | ||
let regexp = /tu regexp/g; | ||
let str = '<> <a href="/"> <input type="radio" checked> <b>'; | ||
alert( str.match(regexp) ); // '<a href="/">', '<input type="radio" checked>', '<b>' | ||
``` | ||
Asumimos que los atributos de etiqueta no deben contener `<`ni `>` (dentro de comillas dobles también),esto simplifica un poco las cosas. |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.