2018-10-10 18:03:03 -04:00
---
id: 587d7db6367417b2b2512b9a
2021-02-06 04:42:36 +00:00
title: Match Characters that Occur Zero or More Times
2018-10-10 18:03:03 -04:00
challengeType: 1
2020-08-04 15:14:01 +08:00
forumTopicId: 301351
2021-01-13 03:31:00 +01:00
dashedName: match-characters-that-occur-zero-or-more-times
2018-10-10 18:03:03 -04:00
---
2020-12-16 00:37:30 -07:00
# --description--
2021-02-06 04:42:36 +00:00
The last challenge used the plus `+` sign to look for characters that occur one or more times. There's also an option that matches characters that occur zero or more times.
2020-12-16 00:37:30 -07:00
2021-02-06 04:42:36 +00:00
The character to do this is the asterisk or star: `*` .
2020-08-04 15:14:01 +08:00
```js
let soccerWord = "gooooooooal!";
let gPhrase = "gut feeling";
let oPhrase = "over the moon";
let goRegex = /go*/;
soccerWord.match(goRegex); // Returns ["goooooooo"]
gPhrase.match(goRegex); // Returns ["g"]
oPhrase.match(goRegex); // Returns null
```
2020-12-16 00:37:30 -07:00
# --instructions--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
For this challenge, `chewieQuote` has been initialized as "Aaaaaaaaaaaaaaaarrrgh!" behind the scenes. Create a regex `chewieRegex` that uses the `*` character to match an uppercase `"A"` character immediately followed by zero or more lowercase `"a"` characters in `chewieQuote` . Your regex does not need flags or character classes, and it should not match any of the other quotes.
2020-12-16 00:37:30 -07:00
# --hints--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex `chewieRegex` should use the `*` character to match zero or more `a` characters.
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(/\*/.test(chewieRegex.source));
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex should match `"A"` in `chewieQuote` .
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(result[0][0] === 'A');
2018-10-10 18:03:03 -04:00
```
2021-02-06 04:42:36 +00:00
Your regex should match `"Aaaaaaaaaaaaaaaa"` in `chewieQuote` .
2020-12-16 00:37:30 -07:00
```js
assert(result[0] === 'Aaaaaaaaaaaaaaaa');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex `chewieRegex` should match 16 characters in `chewieQuote` .
2020-08-04 15:14:01 +08:00
```js
2020-12-16 00:37:30 -07:00
assert(result[0].length === 16);
2020-08-04 15:14:01 +08:00
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex should not match any characters in "He made a fair move. Screaming about it can't help you."
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(
!"He made a fair move. Screaming about it can't help you.".match(chewieRegex)
);
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Your regex should not match any characters in "Let him have it. It's not wise to upset a Wookiee."
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(
!"Let him have it. It's not wise to upset a Wookiee.".match(chewieRegex)
);
2018-10-10 18:03:03 -04:00
```
2020-08-04 15:14:01 +08:00
2021-01-13 03:31:00 +01:00
# --seed--
## --before-user-code--
```js
const chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
```
## --seed-contents--
```js
// Only change code below this line
let chewieRegex = /change/; // Change this line
// Only change code above this line
let result = chewieQuote.match(chewieRegex);
```
2020-12-16 00:37:30 -07:00
# --solutions--
2021-01-13 03:31:00 +01:00
```js
let chewieRegex = /Aa*/;
let result = chewieQuote.match(chewieRegex);
```