freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-an.../regular-expressions/match-letters-of-the-alphab...

2.5 KiB

id title challengeType videoUrl localeTitle
587d7db5367417b2b2512b96 Match Letters of the Alphabet 1 Combina las letras del alfabeto

Description

Vio cómo puede usar los character sets para especificar un grupo de caracteres para hacer coincidir, pero eso es mucho para escribir cuando necesita hacer coincidir una gran variedad de caracteres (por ejemplo, todas las letras del alfabeto). Afortunadamente, hay una característica incorporada que hace que esto sea breve y simple. Dentro de un character set , puede definir un rango de caracteres para hacer coincidir usando un carácter de hyphen : - . Por ejemplo, para que coincida con las letras minúsculas a medio e que usaría [ae] .
vamos catStr = "gato";
dejar batStr = "bat";
dejar matStr = "mat";
vamos bgRegex = / [ae] en /;
catStr.match (bgRegex); // Devoluciones ["cat"]
batStr.match (bgRegex); // Devoluciones ["bat"]
matStr.match (bgRegex); // Devoluciones nulas

Instructions

Coinciden con todas las letras en la cadena quoteSample . Nota
Asegúrese de hacer coincidir las letras mayúsculas y minúsculas .

Tests

tests:
  - text: Su regex <code>alphabetRegex</code> debe coincidir con 35 elementos.
    testString: 'assert(result.length == 35, "Your regex <code>alphabetRegex</code> should match 35 items.");'
  - text: Su regex <code>alphabetRegex</code> debe usar la bandera global.
    testString: 'assert(alphabetRegex.flags.match(/g/).length == 1, "Your regex <code>alphabetRegex</code> should use the global flag.");'
  - text: Su regex <code>alphabetRegex</code> debe usar la bandera que no distingue entre mayúsculas y minúsculas.
    testString: 'assert(alphabetRegex.flags.match(/i/).length == 1, "Your regex <code>alphabetRegex</code> should use the case insensitive flag.");'

Challenge Seed

let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /change/; // Change this line
let result = alphabetRegex; // Change this line

Solution

// solution required