--- id: 587d7db4367417b2b2512b90 title: Match a Literal String with Different Possibilities challengeType: 1 forumTopicId: 301345 localeTitle: Сопоставьте литеральную строку с различными возможностями --- ## Description
Используя регулярные выражения, такие как /coding/ , вы можете искать шаблон "coding" в другой строке. Это мощно для поиска одиночных строк, но ограничивается только одним шаблоном. Вы можете искать несколько шаблонов с помощью alternation или оператора OR : | , Этот оператор соответствует шаблонам до или после него. Например, если вы хотите совместить "yes" или "no" , вам нужно иметь регулярное выражение /yes|no/ . Вы также можете искать не более двух шаблонов. Вы можете сделать это, добавив больше шаблонов с большим количеством операторов OR разделяющих их, например /yes|no|maybe/ .
## Instructions
Complete the regex petRegex to match the pets "dog", "cat", "bird", or "fish".
## Tests
```yml tests: - text: Your regex petRegex should return true for the string "John has a pet dog." testString: assert(petRegex.test('John has a pet dog.')); - text: Your regex petRegex should return false for the string "Emma has a pet rock." testString: assert(!petRegex.test('Emma has a pet rock.')); - text: Your regex petRegex should return true for the string "Emma has a pet bird." testString: assert(petRegex.test('Emma has a pet bird.')); - text: Your regex petRegex should return true for the string "Liz has a pet cat." testString: assert(petRegex.test('Liz has a pet cat.')); - text: Your regex petRegex should return false for the string "Kara has a pet dolphin." testString: assert(!petRegex.test('Kara has a pet dolphin.')); - text: Your regex petRegex should return true for the string "Alice has a pet fish." testString: assert(petRegex.test('Alice has a pet fish.')); - text: Your regex petRegex should return false for the string "Jimmy has a pet computer." testString: assert(!petRegex.test('Jimmy has a pet computer.')); ```
## Challenge Seed
```js let petString = "James has a pet cat."; let petRegex = /change/; // Change this line let result = petRegex.test(petString); ```
## Solution
```js let petString = "James has a pet cat."; let petRegex = /dog|cat|bird|fish/; // Change this line let result = petRegex.test(petString); ```