Placement of \b on step 4

Screen Link:

Why is the answer:

r"\b[Cc]\b[^.+]"

and not:

r"\b[Cc][^.+]\b"

I see that the \b is BEFORE the negative set and not after. I thought it would be after. My thought process was that since we are excluding “C++” or “C.E.O”, the word boundry would be after the “+” and “.” that we want to exclude.

Thank you

1 Like

Hi @gosaints,

A word boundary \b is practically a boundary between “word characters” (which are capital and small letters, digits and underscore [a-zA-Z0-9_], i.e. all the symbols represented by \w) and “not word characters” (all the others, represented by \W). Correspondingly, the dot . and the + are related to the “not word characters”. Hence, in this case we are interested to find the word boundary before the negative set.

2 Likes