I have searched through some questions but couldn\'t find the exact answer i am looking for. I have a requirement to search through large strings of text looking for keywords m
Escape the pattern using Regex.Escape and replace the context-dependent \b word boundaries with (? / (?!\w) lookarounds:
var rx = $@"(?
The (? is a negative lookbehind that fails the match if there is a start of string or a non-word char immediately before the current location, and (?!\w) is a negative looahead that fails the match if there is an end of string or a non-word char immediately after the current location.