Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

698 B

title
title
Match a Literal String with Different Possibilities

Match a Literal String with Different Possibilities


Problem Explanation

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

Inside the string literal, place the pet names, each seperated by the | symbol.


Solutions

Solution 1 (Click to Show/Hide)
let petString = "James has a pet cat.";
let petRegex = /dog|cat|bird|fish/;
let result = petRegex.test(petString);