Search⌘ K
AI Features

Working with Backreferences

Explore how to reuse previously matched sub-strings within regular expressions using backreferences in C#. Understand different backreference syntaxes including numbered, named, and special placeholders to manipulate and transform strings effectively.

Backreferences

Backreferences allow us to reuse previously matched sub-strings within a regular expression pattern. A backreference matches the same sub-string that a capture group already matches.

Using \\n for backreferencing

To create a backreference, we use the following syntax:

\\n

Here, ...