Regular Expressions With C# and .NET 7
This article is an (adapted) excerpt from the book C# 11 and .NET 7 – Modern Cross-Platform Development Fundamentals, and takes you step-by-step through creating a console app to explore regular expressions via some cool new .NET 7 features: the [StringSyntax] attribute and source-generated regular expressions.
Regular expressions are useful for validating input from the user. They are very powerful and can get very complicated. Almost all programming languages have support for regular expressions and use a common set of special characters to define them. Let’s try out some example regular expressions.
Use your preferred code editor to add a new Console App/console project named WorkingWithRegularExpressions to your solution/workspace.
using System.Text.RegularExpressions; // Regex