-2

I have this code

const paragraph = 'my name is bright and this is a testing interface, right.';
const regex = /\b(b)/g;
const found = paragraph.match(regex);

console.log(found);

What i want is that i want to get the whole word instead of just a single letter.

e.g the output in this code above is b which is gotten from the string bright in the paragraph but i don't just want the b but the word bright as a whole and still be able to manipulate it like make it bolder or something else. Please how do i do it and i have also checked other similar questions on stackoverflow but nothing

1 Answers1

-1

Assuming you only want to match words delimited by spaces, this should do the trick.

((?:\w)+)
Bren
  • 605
  • 4
  • 15