2018-09-30 23:01:58 +01:00
---
id: 587d7db5367417b2b2512b97
title: Match Numbers and Letters of the Alphabet
challengeType: 1
2019-08-05 09:17:33 -07:00
forumTopicId: 301356
2021-01-13 03:31:00 +01:00
dashedName: match-numbers-and-letters-of-the-alphabet
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
Using the hyphen (`-` ) to match a range of characters is not limited to letters. It also works to match a range of numbers.
For example, `/[0-5]/` matches any number between `0` and `5` , including the `0` and `5` .
2018-09-30 23:01:58 +01:00
Also, it is possible to combine a range of letters and numbers in a single character set.
2019-05-17 06:20:30 -07:00
```js
let jennyStr = "Jenny8675309";
let myRegex = /[a-z0-9]/ig;
// matches all letters and numbers in jennyStr
jennyStr.match(myRegex);
```
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
Create a single regex that matches a range of letters between `h` and `s` , and a range of numbers between `2` and `6` . Remember to include the appropriate flags in the regex.
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 `myRegex` should match 17 items.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(result.length == 17);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
Your regex `myRegex` should use the global flag.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(myRegex.flags.match(/g/).length == 1);
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Your regex `myRegex` should use the case insensitive flag.
2018-09-30 23:01:58 +01:00
```js
2020-11-27 19:02:05 +01:00
assert(myRegex.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 = "Blueberry 3.141592653s are delicious.";
let myRegex = /change/; // Change this line
let result = myRegex; // 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 = "Blueberry 3.141592653s are delicious.";
let myRegex = /[h-s2-6]/gi; // Change this line
let result = quoteSample.match(myRegex); // Change this line
2018-09-30 23:01:58 +01:00
```