Using Regular Expressions Metacharacters with .net – Anchors and Other "Zero-Width Assertions"
Anchors and other "zero-width assertions" don’t match actual text, but rather positions in the text.
^, \A
Caret (^) matches at the beginning of the text being searched, and, if in an enhanced line-anchor match mode, after any newline. In some systems, an enhanced-mode ^ can match after Unicode line terminators, as well. While \A always matches only at the start of the text being searched, regardless of any match mode.
$, \Z, \z
Dollar ($) matches at the end of the target string, and before a string-ending newline, as well. \Z usually matches the end of the string, or before a string-ending newline. To complement these, \Z matches only at the end of the string, period, without regard to any newline.
\G
\G was first introduced by Perl to be useful when doing iterative matching with /g, and ostensibly matches the location where the previous match left off. On the first iteration, \G matches only at the beginning of the string, just like \A.
Word boundaries – \b, \B, \<, \>
Like line anchors, word-boundary anchors match a location in the string. There are two distinct approaches. One provides separate metasequences for start- and end of-word boundaries (often \< and \>), while the other provides ones catch-all word boundary metasequence (often \b). Either generally provides a not-word boundary metasequence as well (often \B).
Lookarounds – (?=exp), (?<=exp), (?!exp), (?<!exp)
Read more about Lookahead and Lookbehind Zero-Width Assertions.





[...] Using Regular Expressions Metacharacters with .net – Anchors and Other Zero-Width Assertions [...]