I'm just getting into this from regular expressions. And I want to try to do as a word finder, to the most whatsapp style. What do you place to search for a word or letter and it shows you all the coincidences.
The question is as follows.
let regex1 = new RegExp(/l/gi);
let texto = "Cualquier texto";
let array;
while((array = regex1.exec(str1)) !== null){
let index = regex1.lastIndex;
let oracion = str1.split(' ');
console.log('Encontramos una coincidencia en ${array[0]}.
Esta en ${index} '${oracion[regex1]}'');
There the exec finds me the letter l in the sentence and returns to me the index of where that letter is. But I want you to also return the entire word to me.
That code will take you out of the DevMoz examples page. I am also trying to split and configuring the regular expression well with all the necessary symbols but I still do not hit the spot.
I hope you understand me and can help me.