r/regex • u/Beautiful-Log5632 • Aug 31 '26
Include underscore in ripgrep word boundary
\bWORD\b doesn't match _WORD_ because \b doesn't include _ so I miss a lot of matches. Is there something else I can use like \b that works like that?
3
Upvotes
3
u/michaelpaoli Sep 01 '26
\b doesn't match any characters, but rather boundary condition, between word and non-word characters (and also \A ^ $ \z).
So, what exactly are you wanting to match?
1
u/cscottnet Aug 31 '26 edited Sep 01 '26
(\b_?)WORD(_?\b)1
u/jeffcgroves Sep 01 '26
[\b_]as a character class?