\\b is the word boundary. This means that it coincides between a word and a symbol other than a word. + and # are non-character characters, so you need c++ or c# followed by a letter, number, or underscore. Try deleting \\b or replacing it with \\b (which will require another character without a word after + or # ).
Note that when you use find , you also don't need it .* . find will happily return partial matches. Your template will give you the last appearance of either c++ or c# in the first capture group. If this is not what you want, remove the parentheses and wildcards.
Working demo
EDIT: If you add other alternatives that do end with word characters (like java ). The purest solution is not to use \\b or \\b at all, but create your own boundary condition using a negative result. So you just say "match if there is no next character of the word":
\\b(c\\+\\+|c
Working demonstration.
source share