chore(i8n,curriculum): processed translations (#41668)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7db3367417b2b2512b8f
|
||||
title: Match Literal Strings
|
||||
title: Haz coincidir cadenas literales
|
||||
challengeType: 1
|
||||
forumTopicId: 301355
|
||||
dashedName: match-literal-strings
|
||||
@@ -8,44 +8,46 @@ dashedName: match-literal-strings
|
||||
|
||||
# --description--
|
||||
|
||||
In the last challenge, you searched for the word `"Hello"` using the regular expression `/Hello/`. That regex searched for a literal match of the string `"Hello"`. Here's another example searching for a literal match of the string `"Kevin"`:
|
||||
En el desafío anterior, buscaste la palabra `Hello` usando la expresión regular `/Hello/`. Esa expresión regular buscó una coincidencia literal de la cadena `Hello`. Aquí hay otro ejemplo donde se busca una coincidencia literal de la cadena `Kevin`:
|
||||
|
||||
```js
|
||||
let testStr = "Hello, my name is Kevin.";
|
||||
let testRegex = /Kevin/;
|
||||
testRegex.test(testStr);
|
||||
// Returns true
|
||||
```
|
||||
|
||||
Any other forms of `"Kevin"` will not match. For example, the regex `/Kevin/` will not match `"kevin"` or `"KEVIN"`.
|
||||
Esta llamada a `test` devolverá `true`.
|
||||
|
||||
Cualquier otra variante de `Kevin` no coincidirá. Por ejemplo, la expresión regular `/Kevin/` no coincidirá con `kevin` o `KEVIN`.
|
||||
|
||||
```js
|
||||
let wrongRegex = /kevin/;
|
||||
wrongRegex.test(testStr);
|
||||
// Returns false
|
||||
```
|
||||
|
||||
A future challenge will show how to match those other forms as well.
|
||||
Esta llamada a `test` devolverá `false`.
|
||||
|
||||
Un futuro desafío también mostrará cómo coincidir esas otras variantes.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Complete the regex `waldoRegex` to find `"Waldo"` in the string `waldoIsHiding` with a literal match.
|
||||
Completa la expresión regular `waldoRegex` para encontrar `"Waldo"` en la cadena `waldoIsHiding` con una coincidencia literal.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex `waldoRegex` should find `"Waldo"`
|
||||
Tu expresión regular `waldoRegex` debe encontrar la cadena `Waldo`
|
||||
|
||||
```js
|
||||
assert(waldoRegex.test(waldoIsHiding));
|
||||
```
|
||||
|
||||
Your regex `waldoRegex` should not search for anything else.
|
||||
Tu expresión regular `waldoRegex` no debe buscar ninguna otra cosa.
|
||||
|
||||
```js
|
||||
assert(!waldoRegex.test('Somewhere is hiding in this text.'));
|
||||
```
|
||||
|
||||
You should perform a literal string match with your regex.
|
||||
Debes realizar una coincidencia de cadena literal con tu expresión regular.
|
||||
|
||||
```js
|
||||
assert(!/\/.*\/i/.test(code));
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7db9367417b2b2512ba4
|
||||
title: Match Non-Whitespace Characters
|
||||
title: Haz coincidir caracteres que no sean espacios en blanco
|
||||
challengeType: 1
|
||||
forumTopicId: 18210
|
||||
dashedName: match-non-whitespace-characters
|
||||
@@ -8,35 +8,37 @@ dashedName: match-non-whitespace-characters
|
||||
|
||||
# --description--
|
||||
|
||||
You learned about searching for whitespace using `\s`, with a lowercase `s`. You can also search for everything except whitespace.
|
||||
Aprendiste a buscar espacios en blanco usando `\s`, con una `s` en minúscula. También puedes buscar todo excepto los espacios en blanco.
|
||||
|
||||
Search for non-whitespace using `\S`, which is an uppercase `s`. This pattern will not match whitespace, carriage return, tab, form feed, and new line characters. You can think of it being similar to the character class `[^ \r\t\f\n\v]`.
|
||||
Busca caracteres que no sean espacios en blanco usando `\S`, la cual es una `s` mayúscula. Este patrón no coincidirá con los caracteres de espacios en blanco, retorno de carro, tabulaciones, alimentación de formulario y saltos de línea. Puedes pensar que es similar a la clase de caracteres `[^ \r\t\f\n\v]`.
|
||||
|
||||
```js
|
||||
let whiteSpace = "Whitespace. Whitespace everywhere!"
|
||||
let nonSpaceRegex = /\S/g;
|
||||
whiteSpace.match(nonSpaceRegex).length; // Returns 32
|
||||
whiteSpace.match(nonSpaceRegex).length;
|
||||
```
|
||||
|
||||
El valor devuelto por el método `.length` sería `32`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the regex `countNonWhiteSpace` to look for multiple non-whitespace characters in a string.
|
||||
Cambia la expresión regular `countNonWhiteSpace` para buscar varios caracteres que no sean espacios en blanco en una cadena.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex should use the global flag.
|
||||
Tu expresión regular debe usar la bandera global.
|
||||
|
||||
```js
|
||||
assert(countNonWhiteSpace.global);
|
||||
```
|
||||
|
||||
Your regex should use the shorthand character `\S` to match all non-whitespace characters.
|
||||
Tu expresión regular debe usar el carácter abreviado `\S` para que coincida con todos los caracteres que no sean espacios en blanco.
|
||||
|
||||
```js
|
||||
assert(/\\S/.test(countNonWhiteSpace.source));
|
||||
```
|
||||
|
||||
Your regex should find 35 non-spaces in `"Men are from Mars and women are from Venus."`
|
||||
Tu expresión regular debe encontrar 35 caracteres que no sean espacios en la cadena `Men are from Mars and women are from Venus.`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@@ -45,13 +47,13 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your regex should find 23 non-spaces in `"Space: the final frontier."`
|
||||
Tu expresión regular debe encontrar 23 caracteres que no sean espacios en la cadena `Space: the final frontier.`
|
||||
|
||||
```js
|
||||
assert('Space: the final frontier.'.match(countNonWhiteSpace).length == 23);
|
||||
```
|
||||
|
||||
Your regex should find 21 non-spaces in `"MindYourPersonalSpace"`
|
||||
Tu expresión regular debe encontrar 21 caracteres que no sean espacios en la cadena `MindYourPersonalSpace`
|
||||
|
||||
```js
|
||||
assert('MindYourPersonalSpace'.match(countNonWhiteSpace).length == 21);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7db5367417b2b2512b97
|
||||
title: Match Numbers and Letters of the Alphabet
|
||||
title: Haz coincidir los números y las letras del alfabeto
|
||||
challengeType: 1
|
||||
forumTopicId: 301356
|
||||
dashedName: match-numbers-and-letters-of-the-alphabet
|
||||
@@ -8,38 +8,37 @@ dashedName: match-numbers-and-letters-of-the-alphabet
|
||||
|
||||
# --description--
|
||||
|
||||
Using the hyphen (`-`) to match a range of characters is not limited to letters. It also works to match a range of numbers.
|
||||
Usar el guión (`-`) para coincidir con un rango de caracteres no está limitado a letras. También funciona para hacer coincidir un rango de números.
|
||||
|
||||
For example, `/[0-5]/` matches any number between `0` and `5`, including the `0` and `5`.
|
||||
Por ejemplo, `/[0-5]/` coincide con cualquier número entre `0` y `5`, incluyendo `0` y `5`.
|
||||
|
||||
Also, it is possible to combine a range of letters and numbers in a single character set.
|
||||
Además, es posible combinar un rango de letras y números en un único conjunto de caracteres.
|
||||
|
||||
```js
|
||||
let jennyStr = "Jenny8675309";
|
||||
let myRegex = /[a-z0-9]/ig;
|
||||
// matches all letters and numbers in jennyStr
|
||||
jennyStr.match(myRegex);
|
||||
```
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create a single regex that matches a range of letters between `h` and `s`, and a range of numbers between `2` and `6`. Remember to include the appropriate flags in the regex.
|
||||
Crea una sola expresión regular que coincida con un rango de letras entre `h` y `s`, y un rango de números entre `2` y `6`. Recuerda incluir las banderas apropiadas en la expresión regular.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex `myRegex` should match 17 items.
|
||||
Tu expresión regular `myRegex` debe coincidir con 17 elementos.
|
||||
|
||||
```js
|
||||
assert(result.length == 17);
|
||||
```
|
||||
|
||||
Your regex `myRegex` should use the global flag.
|
||||
Tu expresión regular `myRegex` debe utilizar la bandera global.
|
||||
|
||||
```js
|
||||
assert(myRegex.flags.match(/g/).length == 1);
|
||||
```
|
||||
|
||||
Your regex `myRegex` should use the case insensitive flag.
|
||||
Tu expresión regular `myRegex` debe utilizar la bandera que no distingue entre mayúsculas y minúsculas.
|
||||
|
||||
```js
|
||||
assert(myRegex.flags.match(/i/).length == 1);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7dba367417b2b2512ba9
|
||||
title: Positive and Negative Lookahead
|
||||
title: Lookahead positivo y negativo
|
||||
challengeType: 1
|
||||
forumTopicId: 301360
|
||||
dashedName: positive-and-negative-lookahead
|
||||
@@ -8,88 +8,90 @@ dashedName: positive-and-negative-lookahead
|
||||
|
||||
# --description--
|
||||
|
||||
<dfn>Lookaheads</dfn> are patterns that tell JavaScript to look-ahead in your string to check for patterns further along. This can be useful when you want to search for multiple patterns over the same string.
|
||||
Los <dfn>lookaheads</dfn> son patrones que le indican a JavaScript que busque por anticipado en tu cadena para verificar patrones más adelante. Esto puede ser útil cuando deseas buscar varios patrones sobre la misma cadena.
|
||||
|
||||
There are two kinds of lookaheads: <dfn>positive lookahead</dfn> and <dfn>negative lookahead</dfn>.
|
||||
Hay dos tipos de lookaheads: <dfn>lookahead positivo</dfn> y <dfn>lookahead negativo</dfn>.
|
||||
|
||||
A positive lookahead will look to make sure the element in the search pattern is there, but won't actually match it. A positive lookahead is used as `(?=...)` where the `...` is the required part that is not matched.
|
||||
Un lookahead positivo buscará para asegurarse de que el elemento en el patrón de búsqueda este allí, pero en realidad no lo coincidirá. Un lookahead positivo se usa como `(?=...)` donde el `...` es la parte requerida que no coincide.
|
||||
|
||||
On the other hand, a negative lookahead will look to make sure the element in the search pattern is not there. A negative lookahead is used as `(?!...)` where the `...` is the pattern that you do not want to be there. The rest of the pattern is returned if the negative lookahead part is not present.
|
||||
Por otro lado, un lookahead negativo buscará para asegurarse de que el elemento en el patrón de búsqueda no este allí. Un lookahead negativo se usa como `(?!...)` donde el `...` es el patrón que no quieres que esté allí. El resto del patrón se devuelve si la parte de lookahead negativo no está presente.
|
||||
|
||||
Lookaheads are a bit confusing but some examples will help.
|
||||
Los lookaheads son un poco confusos, pero algunos ejemplos ayudarán.
|
||||
|
||||
```js
|
||||
let quit = "qu";
|
||||
let noquit = "qt";
|
||||
let quRegex= /q(?=u)/;
|
||||
let qRegex = /q(?!u)/;
|
||||
quit.match(quRegex); // Returns ["q"]
|
||||
noquit.match(qRegex); // Returns ["q"]
|
||||
quit.match(quRegex);
|
||||
noquit.match(qRegex);
|
||||
```
|
||||
|
||||
A more practical use of lookaheads is to check two or more patterns in one string. Here is a (naively) simple password checker that looks for between 3 and 6 characters and at least one number:
|
||||
Ambas llamadas a `match` devolverán `["q"]`.
|
||||
|
||||
Un uso más práctico de lookaheads es comprobar dos o más patrones en una cadena. Aquí hay un verificador de contraseñas (ingenuamente) simple que busca entre 3 y 6 caracteres y al menos un número:
|
||||
|
||||
```js
|
||||
let password = "abc123";
|
||||
let checkPass = /(?=\w{3,6})(?=\D*\d)/;
|
||||
checkPass.test(password); // Returns true
|
||||
checkPass.test(password);
|
||||
```
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use lookaheads in the `pwRegex` to match passwords that are greater than 5 characters long, and have two consecutive digits.
|
||||
Utiliza los lookaheads en el `pwRegex` para que coincida con las contraseñas que tengan más de 5 caracteres y dos dígitos consecutivos.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex should use two positive `lookaheads`.
|
||||
Tu expresión regular debe usar dos `lookaheads` positivos.
|
||||
|
||||
```js
|
||||
assert(pwRegex.source.match(/\(\?=.*?\)\(\?=.*?\)/) !== null);
|
||||
```
|
||||
|
||||
Your regex should not match `"astronaut"`
|
||||
Tu expresión regular no debe coincidir con la cadena `astronaut`
|
||||
|
||||
```js
|
||||
assert(!pwRegex.test('astronaut'));
|
||||
```
|
||||
|
||||
Your regex should not match `"banan1"`
|
||||
Tu expresión regular no debe coincidir con la cadena `banan1`
|
||||
|
||||
```js
|
||||
assert(!pwRegex.test('banan1'));
|
||||
```
|
||||
|
||||
Your regex should match `"bana12"`
|
||||
Tu expresión regular debe coincidir con la cadena `bana12`
|
||||
|
||||
```js
|
||||
assert(pwRegex.test('bana12'));
|
||||
```
|
||||
|
||||
Your regex should match `"abc123"`
|
||||
Tu expresión regular debe coincidir con la cadena `abc123`
|
||||
|
||||
```js
|
||||
assert(pwRegex.test('abc123'));
|
||||
```
|
||||
|
||||
Your regex should not match `"12345"`
|
||||
Tu expresión regular no debe coincidir con la cadena `12345`
|
||||
|
||||
```js
|
||||
assert(!pwRegex.test('12345'));
|
||||
```
|
||||
|
||||
Your regex should match `"8pass99"`
|
||||
Tu expresión regular debe coincidir con la cadena `8pass99`
|
||||
|
||||
```js
|
||||
assert(pwRegex.test('8pass99'));
|
||||
```
|
||||
|
||||
Your regex should not match `"1a2bcde"`
|
||||
Tu expresión regular no debe coincidir con la cadena `1a2bcde`
|
||||
|
||||
```js
|
||||
assert(!pwRegex.test('1a2bcde'));
|
||||
```
|
||||
|
||||
Your regex should match `"astr1on11aut"`
|
||||
Tu expresión regular debe coincidir con la cadena `astr1on11aut`
|
||||
|
||||
```js
|
||||
assert(pwRegex.test('astr1on11aut'));
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7db8367417b2b2512ba2
|
||||
title: Restrict Possible Usernames
|
||||
title: Restringe posibles nombres de usuario
|
||||
challengeType: 1
|
||||
forumTopicId: 301363
|
||||
dashedName: restrict-possible-usernames
|
||||
@@ -8,96 +8,102 @@ dashedName: restrict-possible-usernames
|
||||
|
||||
# --description--
|
||||
|
||||
Usernames are used everywhere on the internet. They are what give users a unique identity on their favorite sites.
|
||||
Los nombres de usuario se utilizan en todas partes en Internet. Son los que dan a los usuarios una identidad única en tus sitios favoritos.
|
||||
|
||||
You need to check all the usernames in a database. Here are some simple rules that users have to follow when creating their username.
|
||||
Se necesita comprobar todos los nombres de usuario en una base de datos. Estas son algunas reglas simples que los usuarios deben seguir al crear su nombre de usuario.
|
||||
|
||||
1) Usernames can only use alpha-numeric characters.
|
||||
1) Los nombres de usuario sólo pueden utilizar caracteres alfanuméricos.
|
||||
|
||||
2) The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.
|
||||
2) Los únicos números del nombre de usuario tienen que estar al final. Puede tener un cero o más al final. El nombre de usuario no puede iniciar con un número.
|
||||
|
||||
3) Username letters can be lowercase and uppercase.
|
||||
3) Las letras del nombre de usuario pueden ser minúsculas y mayúsculas.
|
||||
|
||||
4) Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.
|
||||
4) Los nombres de usuario deben tener al menos dos caracteres. Un nombre de usuario de dos caracteres sólo puede utilizar letras del alfabeto como caracteres.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the regex `userCheck` to fit the constraints listed above.
|
||||
Cambia la expresión regular `userCheck` para que se ajuste a las restricciones indicadas anteriormente.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex should match `JACK`
|
||||
Tu expresión regular debe coincidir con la cadena `JACK`
|
||||
|
||||
```js
|
||||
assert(userCheck.test('JACK'));
|
||||
```
|
||||
|
||||
Your regex should not match `J`
|
||||
Tu expresión regular no debe coincidir con la cadena `J`
|
||||
|
||||
```js
|
||||
assert(!userCheck.test('J'));
|
||||
```
|
||||
|
||||
Your regex should match `Jo`
|
||||
Tu expresión regular debe coincidir con la cadena `Jo`
|
||||
|
||||
```js
|
||||
assert(userCheck.test('Jo'));
|
||||
```
|
||||
|
||||
Your regex should match `Oceans11`
|
||||
Tu expresión regular debe coincidir con la cadena `Oceans11`
|
||||
|
||||
```js
|
||||
assert(userCheck.test('Oceans11'));
|
||||
```
|
||||
|
||||
Your regex should match `RegexGuru`
|
||||
Tu expresión regular debe coincidir con la cadena `RegexGuru`
|
||||
|
||||
```js
|
||||
assert(userCheck.test('RegexGuru'));
|
||||
```
|
||||
|
||||
Your regex should not match `007`
|
||||
Tu expresión regular no debe coincidir con la cadena `007`
|
||||
|
||||
```js
|
||||
assert(!userCheck.test('007'));
|
||||
```
|
||||
|
||||
Your regex should not match `9`
|
||||
Tu expresión regular no debe coincidir con la cadena `9`
|
||||
|
||||
```js
|
||||
assert(!userCheck.test('9'));
|
||||
```
|
||||
|
||||
Your regex should not match `A1`
|
||||
Tu expresión regular no debe coincidir con la cadena `A1`
|
||||
|
||||
```js
|
||||
assert(!userCheck.test('A1'));
|
||||
```
|
||||
|
||||
Your regex should not match `BadUs3rnam3`
|
||||
Tu expresión regular no debe coincidir con la cadena `BadUs3rnam3`
|
||||
|
||||
```js
|
||||
assert(!userCheck.test('BadUs3rnam3'));
|
||||
```
|
||||
|
||||
Your regex should match `Z97`
|
||||
Tu expresión regular debe coincidir con la cadena `Z97`
|
||||
|
||||
```js
|
||||
assert(userCheck.test('Z97'));
|
||||
```
|
||||
|
||||
Your regex should not match `c57bT3`
|
||||
Tu expresión regular no debe coincidir con la cadena `c57bT3`
|
||||
|
||||
```js
|
||||
assert(!userCheck.test('c57bT3'));
|
||||
```
|
||||
|
||||
Your regex should match `AB1`
|
||||
Tu expresión regular debe coincidir con la cadena `AB1`
|
||||
|
||||
```js
|
||||
assert(userCheck.test('AB1'));
|
||||
```
|
||||
|
||||
Tu expresión regular no debe coincidir con la cadena `J%4`
|
||||
|
||||
```js
|
||||
assert(!userCheck.test('J%4'))
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7dbb367417b2b2512baa
|
||||
title: Reuse Patterns Using Capture Groups
|
||||
title: Reutiliza patrones usando grupos de captura
|
||||
challengeType: 1
|
||||
forumTopicId: 301364
|
||||
dashedName: reuse-patterns-using-capture-groups
|
||||
@@ -8,78 +8,80 @@ dashedName: reuse-patterns-using-capture-groups
|
||||
|
||||
# --description--
|
||||
|
||||
Some patterns you search for will occur multiple times in a string. It is wasteful to manually repeat that regex. There is a better way to specify when you have multiple repeat substrings in your string.
|
||||
Algunos patrones que busques aparecerán múltiples veces en una cadena. Es un desperdicio repetir manualmente esa expresión regular. Existe una mejor forma de especificar que tienes múltiples subcadenas repetidas en tu cadena.
|
||||
|
||||
You can search for repeat substrings using <dfn>capture groups</dfn>. Parentheses, `(` and `)`, are used to find repeat substrings. You put the regex of the pattern that will repeat in between the parentheses.
|
||||
Puedes buscar subcadenas repetidas utilizando <dfn>grupos de captura</dfn>. Los paréntesis, `(` y `)`, son usados para encontrar subcadenas repetidas. Introduces la expresión regular del patrón que se repetirá entre los paréntesis.
|
||||
|
||||
To specify where that repeat string will appear, you use a backslash (<code>\\</code>) and then a number. This number starts at 1 and increases with each additional capture group you use. An example would be `\1` to match the first group.
|
||||
Para especificar donde aparecerá esa cadena repetida, utilizarás una barra invertida (`\`) y luego un número. Este número inicia en 1 e incrementa con cada grupo de captura adicional que utilices. Un ejemplo podría ser `\1` para coincidir con el primer grupo.
|
||||
|
||||
The example below matches any word that occurs twice separated by a space:
|
||||
El siguiente ejemplo encuentra cualquier palabra que ocurra dos veces separada por un espacio:
|
||||
|
||||
```js
|
||||
let repeatStr = "regex regex";
|
||||
let repeatRegex = /(\w+)\s\1/;
|
||||
repeatRegex.test(repeatStr); // Returns true
|
||||
repeatStr.match(repeatRegex); // Returns ["regex regex", "regex"]
|
||||
repeatRegex.test(repeatStr);
|
||||
repeatStr.match(repeatRegex);
|
||||
```
|
||||
|
||||
Using the `.match()` method on a string will return an array with the string it matches, along with its capture group.
|
||||
La llamada a la función `test` devolverá `true`, y la llamada a la función `match` devolverá `["regex regex", "regex"]`.
|
||||
|
||||
Utilizar el método `.match()` en una cadena devuelve un arreglo con la cadena que coincide, junto con su grupo de captura.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use capture groups in `reRegex` to match a string that consists of only the same number repeated exactly three times separated by single spaces.
|
||||
Utiliza los grupos de captura en `reRegex` para que coincida con una cadena que conste sólo del mismo número repetido exactamente tres veces separado por espacios.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex should use the shorthand character class for digits.
|
||||
Tu expresión regular debe utilizar la clase de caracteres abreviada para los dígitos.
|
||||
|
||||
```js
|
||||
assert(reRegex.source.match(/\\d/));
|
||||
```
|
||||
|
||||
Your regex should reuse a capture group twice.
|
||||
Tu expresión regular debe reutilizar un grupo de captura dos veces.
|
||||
|
||||
```js
|
||||
assert(reRegex.source.match(/\\1|\\2/g).length >= 2);
|
||||
```
|
||||
|
||||
Your regex should match `"42 42 42"`.
|
||||
Tu expresión regular debe coincidir con la cadena `42 42 42`.
|
||||
|
||||
```js
|
||||
assert(reRegex.test('42 42 42'));
|
||||
```
|
||||
|
||||
Your regex should match `"100 100 100"`.
|
||||
Tu expresión regular debe coincidir con la cadena `100 100 100`.
|
||||
|
||||
```js
|
||||
assert(reRegex.test('100 100 100'));
|
||||
```
|
||||
|
||||
Your regex should not match `"42 42 42 42"`.
|
||||
Tu expresión regular no debe coincidir con la cadena `42 42 42 42`.
|
||||
|
||||
```js
|
||||
assert.equal('42 42 42 42'.match(reRegex.source), null);
|
||||
```
|
||||
|
||||
Your regex should not match `"42 42"`.
|
||||
Tu expresión regular no debe coincidir con la cadena `42 42`.
|
||||
|
||||
```js
|
||||
assert.equal('42 42'.match(reRegex.source), null);
|
||||
```
|
||||
|
||||
Your regex should not match `"101 102 103"`.
|
||||
Tu expresión regular no debe coincidir con la cadena `101 102 103`.
|
||||
|
||||
```js
|
||||
assert(!reRegex.test('101 102 103'));
|
||||
```
|
||||
|
||||
Your regex should not match `"1 2 3"`.
|
||||
Tu expresión regular no debe coincidir con la cadena `1 2 3`.
|
||||
|
||||
```js
|
||||
assert(!reRegex.test('1 2 3'));
|
||||
```
|
||||
|
||||
Your regex should match `"10 10 10"`.
|
||||
Tu expresión regular debe coincidir con la cadena `10 10 10`.
|
||||
|
||||
```js
|
||||
assert(reRegex.test('10 10 10'));
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7db9367417b2b2512ba6
|
||||
title: Specify Only the Lower Number of Matches
|
||||
title: Especifica solo el menor número de coincidencias
|
||||
challengeType: 1
|
||||
forumTopicId: 301366
|
||||
dashedName: specify-only-the-lower-number-of-matches
|
||||
@@ -8,65 +8,67 @@ dashedName: specify-only-the-lower-number-of-matches
|
||||
|
||||
# --description--
|
||||
|
||||
You can specify the lower and upper number of patterns with quantity specifiers using curly brackets. Sometimes you only want to specify the lower number of patterns with no upper limit.
|
||||
Puedes especificar el número inferior y superior de patrones mediante especificadores de cantidad utilizando llaves. A veces sólo se quiere especificar el número inferior de patrones sin tener un límite superior.
|
||||
|
||||
To only specify the lower number of patterns, keep the first number followed by a comma.
|
||||
Para especificar sólo el número inferior de patrones, mantén el primer número seguido de una coma.
|
||||
|
||||
For example, to match only the string `"hah"` with the letter `a` appearing at least `3` times, your regex would be `/ha{3,}h/`.
|
||||
Por ejemplo, para hacer coincidir solo con la cadena `hah` cuando la letra `a` aparezca al menos `3` veces, la expresión regular sería `/ha{3,}h/`.
|
||||
|
||||
```js
|
||||
let A4 = "haaaah";
|
||||
let A2 = "haah";
|
||||
let A100 = "h" + "a".repeat(100) + "h";
|
||||
let multipleA = /ha{3,}h/;
|
||||
multipleA.test(A4); // Returns true
|
||||
multipleA.test(A2); // Returns false
|
||||
multipleA.test(A100); // Returns true
|
||||
multipleA.test(A4);
|
||||
multipleA.test(A2);
|
||||
multipleA.test(A100);
|
||||
```
|
||||
|
||||
En orden, las tres llamadas a `test` devuelven `true`, `false` y `true`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the regex `haRegex` to match the word `"Hazzah"` only when it has four or more letter `z`'s.
|
||||
Modifica la expresión regular `haRegex` para coincidir con la palabra `Hazzah` solo cuando ésta tiene cuatro o más letras `z`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex should use curly brackets.
|
||||
La expresión regular debe utilizar llaves.
|
||||
|
||||
```js
|
||||
assert(haRegex.source.match(/{.*?}/).length > 0);
|
||||
```
|
||||
|
||||
Your regex should not match `"Hazzah"`
|
||||
La expresión regular no debe coincidir con la cadena `Hazzah`
|
||||
|
||||
```js
|
||||
assert(!haRegex.test('Hazzah'));
|
||||
```
|
||||
|
||||
Your regex should not match `"Hazzzah"`
|
||||
La expresión regular no debe coincidir con la cadena `Hazzzah`
|
||||
|
||||
```js
|
||||
assert(!haRegex.test('Hazzzah'));
|
||||
```
|
||||
|
||||
Your regex should match `"Hazzzzah"`
|
||||
La expresión regular debe coincidir con la cadena `Hazzzzah`
|
||||
|
||||
```js
|
||||
assert('Hazzzzah'.match(haRegex)[0].length === 8);
|
||||
```
|
||||
|
||||
Your regex should match `"Hazzzzzah"`
|
||||
La expresión regular debe coincidir con la cadena `Hazzzzzah`
|
||||
|
||||
```js
|
||||
assert('Hazzzzzah'.match(haRegex)[0].length === 9);
|
||||
```
|
||||
|
||||
Your regex should match `"Hazzzzzzah"`
|
||||
La expresión regular debe coincidir con la cadena `Hazzzzzzah`
|
||||
|
||||
```js
|
||||
assert('Hazzzzzzah'.match(haRegex)[0].length === 10);
|
||||
```
|
||||
|
||||
Your regex should match `"Hazzah"` with 30 `z`'s in it.
|
||||
La expresión regular debe coincidir con la cadena `Hazzah` con 30 `z`'s.
|
||||
|
||||
```js
|
||||
assert('Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah'.match(haRegex)[0].length === 34);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7db9367417b2b2512ba5
|
||||
title: Specify Upper and Lower Number of Matches
|
||||
title: Especifica el menor y mayor número de coincidencias
|
||||
challengeType: 1
|
||||
forumTopicId: 301367
|
||||
dashedName: specify-upper-and-lower-number-of-matches
|
||||
@@ -8,63 +8,65 @@ dashedName: specify-upper-and-lower-number-of-matches
|
||||
|
||||
# --description--
|
||||
|
||||
Recall that you use the plus sign `+` to look for one or more characters and the asterisk `*` to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns.
|
||||
Recuerda que se utiliza el signo más `+` para buscar uno o más caracteres y el asterisco `*` para buscar cero o más caracteres. Esto es conveniente, pero a veces quieres coincidir con cierta gama de patrones.
|
||||
|
||||
You can specify the lower and upper number of patterns with <dfn>quantity specifiers</dfn>. Quantity specifiers are used with curly brackets (`{` and `}`). You put two numbers between the curly brackets - for the lower and upper number of patterns.
|
||||
Puedes especificar el número inferior y superior de patrones utilizando <dfn>especificadores de cantidad</dfn>. Para los especificadores de cantidad utilizamos llaves (`{` y `}`). Pon dos números entre las llaves - para el número inferior y superior de patrones.
|
||||
|
||||
For example, to match only the letter `a` appearing between `3` and `5` times in the string `"ah"`, your regex would be `/a{3,5}h/`.
|
||||
Por ejemplo, para que coincida con la letra `a` si aparece entre `3` y `5` veces en la cadena `ah`, la expresión regular debe ser `/a{3,5}h/`.
|
||||
|
||||
```js
|
||||
let A4 = "aaaah";
|
||||
let A2 = "aah";
|
||||
let multipleA = /a{3,5}h/;
|
||||
multipleA.test(A4); // Returns true
|
||||
multipleA.test(A2); // Returns false
|
||||
multipleA.test(A4);
|
||||
multipleA.test(A2);
|
||||
```
|
||||
|
||||
La primera llamada a `test` devuelve `true`, mientras que la segunda devuelve `false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the regex `ohRegex` to match the entire phrase `"Oh no"` only when it has `3` to `6` letter `h`'s.
|
||||
Modifica la expresión regular `ohRegex` para que coincida con toda la frase `Oh no` solo cuando tenga de `3` a `6` letras `h`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your regex should use curly brackets.
|
||||
La expresión regular debe utilizar llaves.
|
||||
|
||||
```js
|
||||
assert(ohRegex.source.match(/{.*?}/).length > 0);
|
||||
```
|
||||
|
||||
Your regex should not match `"Ohh no"`
|
||||
La expresión regular no debe coincidir con la cadena `Ohh no`
|
||||
|
||||
```js
|
||||
assert(!ohRegex.test('Ohh no'));
|
||||
```
|
||||
|
||||
Your regex should match `"Ohhh no"`
|
||||
La expresión regular debe coincidir con la cadena `Ohhh no`
|
||||
|
||||
```js
|
||||
assert('Ohhh no'.match(ohRegex)[0].length === 7);
|
||||
```
|
||||
|
||||
Your regex should match `"Ohhhh no"`
|
||||
La expresión regular no debe coincidir con la cadena `Ohhhh no`
|
||||
|
||||
```js
|
||||
assert('Ohhhh no'.match(ohRegex)[0].length === 8);
|
||||
```
|
||||
|
||||
Your regex should match `"Ohhhhh no"`
|
||||
La expresión regular debe coincidir con la cadena `Ohhhhh no`
|
||||
|
||||
```js
|
||||
assert('Ohhhhh no'.match(ohRegex)[0].length === 9);
|
||||
```
|
||||
|
||||
Your regex should match `"Ohhhhhh no"`
|
||||
La expresión regular debe coincidir con la cadena `Ohhhhhh no`
|
||||
|
||||
```js
|
||||
assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);
|
||||
```
|
||||
|
||||
Your regex should not match `"Ohhhhhhh no"`
|
||||
La expresión regular no debe coincidir con la cadena `Ohhhhhhh no`
|
||||
|
||||
```js
|
||||
assert(!ohRegex.test('Ohhhhhhh no'));
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7dbb367417b2b2512bab
|
||||
title: Use Capture Groups to Search and Replace
|
||||
title: Usa grupos de captura para buscar y reemplazar
|
||||
challengeType: 1
|
||||
forumTopicId: 301368
|
||||
dashedName: use-capture-groups-to-search-and-replace
|
||||
@@ -8,55 +8,57 @@ dashedName: use-capture-groups-to-search-and-replace
|
||||
|
||||
# --description--
|
||||
|
||||
Searching is useful. However, you can make searching even more powerful when it also changes (or replaces) the text you match.
|
||||
La búsqueda es útil. Sin embargo, puedes hacer que la búsqueda sea aún más poderosa si también cambias (o reemplazas) el texto con el que coincide.
|
||||
|
||||
You can search and replace text in a string using `.replace()` on a string. The inputs for `.replace()` is first the regex pattern you want to search for. The second parameter is the string to replace the match or a function to do something.
|
||||
Puedes buscar y reemplazar texto en una cadena usando `.replace()` en una cadena. Las entradas para `.replace()` son primero el patrón de expresiones regulares que deseas buscar. El segundo parámetro es la cadena para reemplazar la coincidencia o una función para hacer algo.
|
||||
|
||||
```js
|
||||
let wrongText = "The sky is silver.";
|
||||
let silverRegex = /silver/;
|
||||
wrongText.replace(silverRegex, "blue");
|
||||
// Returns "The sky is blue."
|
||||
```
|
||||
|
||||
You can also access capture groups in the replacement string with dollar signs (`$`).
|
||||
La llamada `replace` devolverá la cadena `The sky is blue.`.
|
||||
|
||||
También puedes acceder a grupos de captura en la cadena de reemplazo con signos de dólar. (`$`).
|
||||
|
||||
```js
|
||||
"Code Camp".replace(/(\w+)\s(\w+)/, '$2 $1');
|
||||
// Returns "Camp Code"
|
||||
```
|
||||
|
||||
La llamada `replace` devolverá la cadena `Camp Code`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a regex `fixRegex` using three capture groups that will search for each word in the string "one two three". Then update the `replaceText` variable to replace "one two three" with the string "three two one" and assign the result to the `result` variable. Make sure you are utilizing capture groups in the replacement string using the dollar sign (`$`) syntax.
|
||||
Escribe una expresión regular `fixRegex` utilizando tres grupos de captura que buscarán cada palabra en la cadena `one two three`. Luego actualiza la variable `replaceText` para reemplazar `one two three` con la cadena `three two one` y asigna el resultado a la variable `result`. Asegúrate de utilizar grupos de captura en la cadena de reemplazo utilizando la sintaxis del signo de dólar (`$`).
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use `.replace()` to search and replace.
|
||||
Debes utilizar `.replace()` para buscar y reemplazar.
|
||||
|
||||
```js
|
||||
assert(code.match(/\.replace\(.*\)/));
|
||||
```
|
||||
|
||||
Your regex should change `"one two three"` to `"three two one"`
|
||||
Tu expresión regular debe cambiar la cadena `one two three` a la cadena `three two one`
|
||||
|
||||
```js
|
||||
assert(result === 'three two one');
|
||||
```
|
||||
|
||||
You should not change the last line.
|
||||
No debes cambiar la última línea.
|
||||
|
||||
```js
|
||||
assert(code.match(/result\s*=\s*str\.replace\(.*?\)/));
|
||||
```
|
||||
|
||||
`fixRegex` should use at least three capture groups.
|
||||
`fixRegex` debe usar al menos tres grupos de captura.
|
||||
|
||||
```js
|
||||
assert(new RegExp(fixRegex.source + '|').exec('').length - 1 >= 3);
|
||||
```
|
||||
|
||||
`replaceText` should use parenthesized submatch string(s) (i.e. the nth parenthesized submatch string, $n, corresponds to the nth capture group).
|
||||
`replaceText` debe usar cadena(s) de subcoincidencia entre paréntesis (es decir, la enésima cadena de subcoincidencia entre parentesis, $n, corresponde al enésimo grupo de captura).
|
||||
|
||||
```js
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7db3367417b2b2512b8e
|
||||
title: Using the Test Method
|
||||
title: Usa el método "test"
|
||||
challengeType: 1
|
||||
forumTopicId: 301369
|
||||
dashedName: using-the-test-method
|
||||
@@ -8,32 +8,33 @@ dashedName: using-the-test-method
|
||||
|
||||
# --description--
|
||||
|
||||
Regular expressions are used in programming languages to match parts of strings. You create patterns to help you do that matching.
|
||||
Las expresiones regulares se utilizan en lenguajes de programación para coincidir con partes de cadenas. Creas patrones para ayudarte a hacer esa coincidencia.
|
||||
|
||||
If you want to find the word `"the"` in the string `"The dog chased the cat"`, you could use the following regular expression: `/the/`. Notice that quote marks are not required within the regular expression.
|
||||
Si quieres encontrar la palabra `the` en la cadena `The dog chased the cat`, puedes utilizar la siguiente expresión regular: `/the/`. Ten en cuenta que las comillas no son requeridas dentro de la expresión regular.
|
||||
|
||||
JavaScript has multiple ways to use regexes. One way to test a regex is using the `.test()` method. The `.test()` method takes the regex, applies it to a string (which is placed inside the parentheses), and returns `true` or `false` if your pattern finds something or not.
|
||||
JavaScript tiene múltiples formas de usar expresiones regulares. Una forma de probar una expresión regular es usando el método `.test()`. El método `.test()` toma la expresión regular, la aplica a una cadena (que se coloca dentro de los paréntesis), y devuelve `true` o `false` si tu patrón encuentra algo o no.
|
||||
|
||||
```js
|
||||
let testStr = "freeCodeCamp";
|
||||
let testRegex = /Code/;
|
||||
testRegex.test(testStr);
|
||||
// Returns true
|
||||
```
|
||||
|
||||
El método `test` aquí devuelve `true`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Apply the regex `myRegex` on the string `myString` using the `.test()` method.
|
||||
Aplica la expresión regular `myRegex` en la cadena `myString` usando el método `.test()`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use `.test()` to test the regex.
|
||||
Debes usar `.test()` para probar la expresión regular.
|
||||
|
||||
```js
|
||||
assert(code.match(/myRegex.test\(\s*myString\s*\)/));
|
||||
```
|
||||
|
||||
Your result should return `true`.
|
||||
Tu resultado debe devolver `true`.
|
||||
|
||||
```js
|
||||
assert(result === true);
|
||||
|
Reference in New Issue
Block a user