Why does /([o])\w+/g not match the word to

Viewed 292

I'm learning regex via regexr.com so that I can be less embarrassingly pathetic when trying to match patterns.

The website provides an explanation for each component of the regex statement, but I'm unable to determine why this expression:

/([o])\w+/g

doesn't match any part of the word "to":

regexr

My understanding is that [o] should match the letter o and the \w switch (or whatever you'd call that... flag? option?) tells it to match words.

I would also benefit from an explanation of why it matches only o and the letters after o within a word (e.g. ome in the word Welcome) rather than the entire word containing the letter o).

Finally, the explanation of + tells me that it means to "match 1 or more of the preceding token" while toggling this seems to control if only 1 letter after o is matched, or all of the letters after o in the word is matched. Clarification on this would be greatly appreciated.

My apologies for the novice questions.

2 Answers
Related