.NET Regex Explainer
Paste a regular expression and get a plain-English breakdown piece by piece, with .NET-specific constructs like balancing groups and inline options called out, plus a live tester and a RegexOptions reference.
Examples
| Piece | Meaning |
|---|
The tester runs your browser's JavaScript engine, which agrees with .NET on everything above except the constructs flagged in the notes. Nothing you type leaves this page.
RegexOptions, in one breath
IgnoreCase | Case-insensitive matching. Inline: (?i) |
Multiline | ^ and $ also match at line breaks. Inline: (?m) |
Singleline | . matches newlines too. Inline: (?s) |
ExplicitCapture | Plain (…) stops capturing; only named groups capture. Inline: (?n) |
IgnorePatternWhitespace | Whitespace in the pattern is ignored and # starts a comment. Inline: (?x) |
Compiled | Compiles to IL for faster repeated use; slower to build, no inline form. |
NonBacktracking | .NET 7+: linear-time matching, immune to catastrophic backtracking; no lookarounds or backreferences. |
RightToLeft | The scan moves right to left. No JavaScript equivalent. |
Always pair a user-facing regex with RegexOptions.NonBacktracking or a matchTimeout - a backtracking pattern on hostile input is a denial of service waiting for a string.