2018-09-30 23:01:58 +01:00
---
id: 587d7db5367417b2b2512b96
title: Match Letters of the Alphabet
challengeType: 1
2019-08-05 09:17:33 -07:00
forumTopicId: 301354
2021-01-13 03:31:00 +01:00
dashedName: match-letters-of-the-alphabet
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2019-10-27 15:45:37 -01:00
You saw how you can use < dfn > character sets< / dfn > to specify a group of characters to match, but that's a lot of typing when you need to match a large range of characters (for example, every letter in the alphabet). Fortunately, there is a built-in feature that makes this short and simple.
2020-11-27 19:02:05 +01:00
Inside a character set, you can define a range of characters to match using a hyphen character: `-` .
For example, to match lowercase letters `a` through `e` you would use `[a-e]` .
2019-05-17 06:20:30 -07:00
```js
let catStr = "cat";
let batStr = "bat";
let matStr = "mat";
let bgRegex = /[a-e]at/;
catStr.match(bgRegex); // Returns ["cat"]
batStr.match(bgRegex); // Returns ["bat"]
matStr.match(bgRegex); // Returns null
```
2020-11-27 19:02:05 +01:00
# --instructions--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Match all the letters in the string `quoteSample` .
2018-09-30 23:01:58 +01:00
2021-01-20 18:01:00 -08:00
**Note**: Be sure to match both uppercase and lowercase letters.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Your regex `alphabetRegex` should match 35 items.
```js
assert(result.length == 35);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
Your regex `alphabetRegex` should use the global flag.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(alphabetRegex.flags.match(/g/).length == 1);
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Your regex `alphabetRegex` should use the case insensitive flag.
2018-09-30 23:01:58 +01:00
```js
2020-11-27 19:02:05 +01:00
assert(alphabetRegex.flags.match(/i/).length == 1);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /change/; // Change this line
let result = alphabetRegex; // Change this line
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
```js
2019-05-03 03:05:26 -07:00
let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /[a-z]/gi; // Change this line
let result = quoteSample.match(alphabetRegex); // Change this line
2018-09-30 23:01:58 +01:00
```