Regular Expressions: Find Characters with Lazy Matching

Regular Expressions: Find Characters with Lazy Matching
0

#1

Tell us what’s happening:
How to make this to return the following array?
[“ti”, “tani”, “titani”]

Your code so far


let text = "titanic";
let myRegex = /t[a-z]*?i/; // Change this line
let result = text.match(myRegex);



Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/find-characters-with-lazy-matching


#2

With loop with different regex.
/^ti$/g
/^tani$/g
/^titani$/
or
loop with index
[A-z]{1index}


#3

What is index in the second example?


#4

index in loop function, while or for or for each. pick what you want.


#5

Why would you want to return an array? That’s not what the challenge is asking.