Regex tester · Guide

Regex Tester .NET: What Makes the .NET Engine Different

Most regex flavours are close enough to swap patterns between them. .NET is the one that genuinely differs, with capabilities no other mainstream engine has — and patterns using them will not run anywhere else.

Variable-length lookbehind

Nearly every engine restricts lookbehind to a fixed width. Java allows bounded ranges, JavaScript allows variable length since ES2018, and PCRE requires fixed. .NET has always allowed anything:

Regex
(?<=^.*:\s*)\w+      # valid in .NET, rejected by PCRE and Python

This makes some parsing tasks dramatically simpler in .NET and makes the resulting pattern non-portable, which matters if it lives in a shared configuration file.

Balancing groups

.NET can match nested structures — genuinely, not approximately — using a capture stack. Matching balanced parentheses is impossible in a regular language and .NET does it anyway:

Regex
^[^()]*(?:(?<open>\()[^()]*|(?<-open>\))[^()]*)*(?(open)(?!))$

(?<-open>...) pops the stack and (?(open)(?!)) fails if anything is left unmatched. It works, it is unreadable, and a real parser is almost always the better answer.

Right-to-left and conditionals

RegexOptions.RightToLeft matches from the end of the string, which is occasionally the natural direction — finding the last occurrence without a greedy prefix.

Conditional matching (?(group)yes|no) branches on whether a group participated. Both features are .NET-only among mainstream engines.

Testing .NET patterns

A generic online tester usually runs a JavaScript or PCRE engine, so .NET-specific constructs will error or behave differently. Test the engine you are targeting.

For portable patterns, stay inside the common subset: character classes, standard quantifiers, non-capturing groups, named groups with (?<name>...), and fixed-length lookbehind. Anything beyond that will need rewriting when the pattern moves.

Frequently asked questions

Are .NET regex patterns portable?

Mostly, unless they use balancing groups, variable-length lookbehind, conditionals or right-to-left matching.

Can .NET regex parse nested structures?

Yes, via balancing groups — but a real parser is clearer and easier to maintain.

Why does my .NET pattern fail in an online tester?

The tester likely runs a JavaScript or PCRE engine that lacks the .NET-specific construct.

Ready to try it?

Open the free browser-based Regex tester and apply what you just read — no sign-up, runs locally.

Open the Regex tester tool