Files
freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/regular-expressions/match-single-character-with-multiple-possibilities.spanish.md
2018-10-08 13:34:43 -04:00

3.3 KiB

id, title, localeTitle, challengeType
id title localeTitle challengeType
587d7db5367417b2b2512b95 Match Single Character with Multiple Possibilities Coincidir con un solo personaje con múltiples posibilidades 1

Description

Aprendió cómo hacer coincidir patrones literales ( /literal/ ) y caracteres comodín ( /./ ). Esos son los extremos de las expresiones regulares, donde uno encuentra coincidencias exactas y el otro todo. Hay opciones que son un equilibrio entre los dos extremos. Puede buscar un patrón literal con cierta flexibilidad con las character classes . Las clases de caracteres le permiten definir un grupo de caracteres que desea hacer coincidiendo colocándolos entre corchetes cuadrados ( [ y ] ). Por ejemplo, desea hacer coincidir "bag" , "big" y "bug" pero no "bog" . Puede crear la expresión regular /b[aiu]g/ para hacer esto. La [aiu] es la clase de caracteres que solo coincidirá con los caracteres "a" , "i" o "u" .
let bigStr = "big";
let bagStr = "bag";
let bugStr = "bug";
let bogStr = "bog";
let bgRegex = /b[aiu]g/;
bigStr.match(bgRegex); // Returns ["big"]
bagStr.match(bgRegex); // Returns ["bag"]
bugStr.match(bgRegex); // Returns ["bug"]
bogStr.match(bgRegex); // Returns null

Instructions

Use una clase de caracteres con vocales ( a , e , i , o , u ) en su regex vowelRegex para encontrar todas las vocales en la cadena quoteSample . Nota
Asegúrese de hacer coincidir las vocales mayúsculas y minúsculas.

Tests

tests:
  - text: Debes encontrar las 25 vocales.
    testString: 'assert(result.length == 25, "You should find all 25 vowels.");'
  - text: Su regex <code class = "notranslate"> vowelRegex </code> debe usar una clase de caracteres.
    testString: 'assert(/\[.*\]/.test(vowelRegex.source), "Your regex <code>vowelRegex</code> should use a character class.");'
  - text: Su regex <code class = "notranslate"> vowelRegex </code> debe usar la bandera global.
    testString: 'assert(vowelRegex.flags.match(/g/).length == 1, "Your regex <code>vowelRegex</code> should use the global flag.");'
  - text: Su regex <code class = "notranslate"> vowelRegex </code> debe usar la marca que no distingue entre mayúsculas y minúsculas.
    testString: 'assert(vowelRegex.flags.match(/i/).length == 1, "Your regex <code>vowelRegex</code> should use the case insensitive flag.");'
  - text: Su expresión regular no debe coincidir con ninguna consonante.
    testString: 'assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()), "Your regex should not match any consonants.");'

Challenge Seed

let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex = /change/; // Change this line
let result = vowelRegex; // Change this line

Solution

// solution required