Open links in new tab
  1. Copilot Answer
    Regular Expression Language - Quick Reference - .NET

    Learn how to use regular expressions in .NET with this quick reference guide. Find out how to escape characters, use character classes, anchors, grouping constructs, and more.

    Microsoft Learn

    A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs. For a brief introduction, see .NET Regular Expressions.

    Each section in this quick reference lists a particular category of characters, operators, and constructs that you can use to define regular expressions.

    We've also provided this information in two formats that you can download and print for easy reference:

    •Download in Word (.docx) format

    Continue reading

    The backslash character (\) in a regular expression indicates that the character that follows it either is a special character (as shown in the following table), or should be interpreted literally. For more information, see Character Escapes.

    Continue reading

    Anchors, or atomic zero-width assertions, cause a match to succeed or fail depending on the current position in the string, but they do not cause the engine to advance through the string or consume characters. The metacharacters listed in the following table are anchors. For more information, see Anchors.

    Continue reading

    Lookarounds at a glance

    When the regular expression engine hits a lookaround expression, it takes a substring reaching from the current position to the start (lookbehind) or end (lookahead) of the original string, and then runs Regex.IsMatch on that substring using the lookaround pattern. Success of this subexpression's result is then determined by whether it's a positive or negative assertion. Once they have matched, atomic groups won't be re-evaluated again, even when the remainder of the pattern fails due to the match. This can significantly improve performance when quantifiers occur within the atomic group or the remainder of the pattern.

    Continue reading
  1. Some results have been removed