2.4 KiB
2.4 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db5367417b2b2512b96 | Match Letters of the Alphabet | 1 | Correspondência de letras do alfabeto |
Description
character sets
para especificar um grupo de caracteres a serem correspondidos, mas isso é muita digitação quando você precisa corresponder a um grande intervalo de caracteres (por exemplo, todas as letras do alfabeto). Felizmente, há um recurso embutido que torna isso simples e curto. Dentro de um character set
, você pode definir um intervalo de caracteres para corresponder usando um caractere de hyphen
: -
. Por exemplo, para corresponder letras minúsculas de a
até e
você usaria [ae]
. deixe catStr = "cat";
deixe batStr = "bat";
let matStr = "mat";
deixe bgRegex = / [ae] em /;
catStr.match (bgRegex); // Retorna ["gato"]
batStr.match (bgRegex); // Retorna ["bat"]
matStr.match (bgRegex); // Retorna nulo
Instructions
quoteSample
. Nota Certifique-se de combinar as letras maiúsculas e minúsculas .
Tests
tests:
- text: Seu regex <code>alphabetRegex</code> deve corresponder a 35 itens.
testString: 'assert(result.length == 35, "Your regex <code>alphabetRegex</code> should match 35 items.");'
- text: Seu regex <code>alphabetRegex</code> deve usar o sinalizador global.
testString: 'assert(alphabetRegex.flags.match(/g/).length == 1, "Your regex <code>alphabetRegex</code> should use the global flag.");'
- text: Seu regex <code>alphabetRegex</code> deve usar o sinalizador insensível a maiúsculas e 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