0

i want to use this

const text = 'The silver ho house is so housey and the other house too.';
const val = 'house';
const exp = `^(.*?(\b${val}\b)[^$]*)$`;
text.match(exp); //should match.

to match a word in a string for e.g.

//The silver ho house is so housey and the other house too.
// match -------^^^^^                    match---^^^^^

But I first have to convert the exp string to a 'real' regular expression and i don't know how to do this properly. RegExp(exp) does not work by the way.

swftowu69
  • 69
  • 7

0 Answers0