xxxxxxxxxx
const searchWord = (string, word) => {
const regex = new RegExp(word, 'gi');
return string.match(regex);
};
const text = "This is an example string.";
const wordToSearch = "example";
const matches = searchWord(text, wordToSearch);
console.log(matches); // Output: ["example"]