I have this regex on mongodb query to match words by prefix:
{sentence: new RegExp(\'^\'+key,\'gi\')}
What would be the right regex pattern
Use the \b anchor to match word boundaries:
\bdo
finds 'do' in 'nice dog', but doesn't match 'much ado about nothing'.