Files

30 lines
698 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Match a Literal String with Different Possibilities
---
# Match a Literal String with Different Possibilities
2018-10-12 15:37:13 -04:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
Suppose you want to match many different words with your regular expression; using the `|` symbol, that becomes possible. In this challenge, you are using that symbol to identify four different pets hidden within strings!
---
## Hints
### Hint 1
2018-10-12 15:37:13 -04:00
Inside the string literal, place the pet names, each seperated by the `|` symbol.
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2018-10-12 15:37:13 -04:00
```js
2018-10-12 15:37:13 -04:00
let petString = "James has a pet cat.";
let petRegex = /dog|cat|bird|fish/;
let result = petRegex.test(petString);
```
</details>