function findNextWord(text, expression) {
const pattern = new RegExp(expression.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '\\s+(\\w+)', 'g');
const match = pattern.exec(text);
if (match) {
console.log(`The first word after '${expression}' is: ${match[1]}`);
} else {
console.log('No match found!');
}
}
const text = 'The quick brown fox jumps over the lazy dog.';
const expression = 'fox';
findNextWord(text, expression);
/*
run:
The first word after 'fox' is: jumps
*/