--- id: 587d7db5367417b2b2512b96 title: Match Letters of the Alphabet challengeType: 1 videoUrl: '' localeTitle: 匹配字母的字母 --- ## Description
您了解了如何使用character sets来指定要匹配的一组字符,但是当您需要匹配大范围的字符(例如,字母表中的每个字母)时,这是很多类型。幸运的是,有一个内置功能,使这简短。在character set ,您可以使用hyphen字符来定义要匹配的hyphen范围: - 。例如,要匹配小写字母ae您将使用[ae]
让catStr =“猫”;
让batStr =“蝙蝠”;
让matStr =“mat”;
让bgRegex = / [ae] at /;
catStr.match(bgRegex); //返回[“cat”]
batStr.match(bgRegex); //返回[“bat”]
matStr.match(bgRegex); //返回null
## Instructions
匹配字符串quoteSample中的所有字母。 注意
务必匹配大写和小写字母
## Tests
```yml tests: - text: 你的正则表达式alphabetRegex应该匹配35项。 testString: 'assert(result.length == 35, "Your regex alphabetRegex should match 35 items.");' - text: 你的正则表达式alphabetRegex应该使用全局标志。 testString: 'assert(alphabetRegex.flags.match(/g/).length == 1, "Your regex alphabetRegex should use the global flag.");' - text: 你的正则表达式alphabetRegex应该使用不区分大小写的标志。 testString: 'assert(alphabetRegex.flags.match(/i/).length == 1, "Your regex alphabetRegex should use the case insensitive flag.");' ```
## Challenge Seed
```js let quoteSample = "The quick brown fox jumps over the lazy dog."; let alphabetRegex = /change/; // Change this line let result = alphabetRegex; // Change this line ```
## Solution
```js // solution required ```