Regular Expressions - Match a Literal String with Different Possibilities

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

while using multiple literal we using OR operator but in case we want to know which word or character is matching?, at this situation using regex is corret option or not?

let petString = "James has a pet cat.";
let petRegex = /dog|cat|bird|fish/; // Change this line
let result = petRegex.test(petString);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

Challenge: Regular Expressions - Match a Literal String with Different Possibilities

Link to the challenge:

You will get to that in later challenges.

you will soon meet “match()”

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.