Permalink
Fetching contributors…
Cannot retrieve contributors at this time
59 lines (47 sloc) 3.38 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
Regular Expression Examples
03/30/2017
.net
dotnet-standard
article
regular expressions [.NET Framework], examples
regular expressions [.NET Framework]
strings [.NET Framework], regular expressions
e9fd53f2-ed56-4b09-b2ea-e9bc9d65e6d6
17
rpetrusha
ronpet
wpickett

Regular Expression Examples

This section contains code examples that illustrate the use of regular expressions in common applications.

[!NOTE] The xref:System.Web.RegularExpressions namespace contains a number of regular expression objects that implement predefined regular expression patterns for parsing strings from HTML, XML, and ASP.NET documents. For example, the xref:System.Web.RegularExpressions.TagRegex class identifies start tags in a string and the xref:System.Web.RegularExpressions.CommentRegex class identifies ASP.NET comments in a string.

In This Section

Example: Scanning for HREFs
Provides an example that searches an input string and prints out all the href="…" values and their locations in the string.

Example: Changing Date Formats
Provides an example that replaces dates in the form mm/dd/yy with dates in the form dd-mm-yy.

How to: Extract a Protocol and Port Number from a URL
Provides an example that extracts a protocol and port number from a string that contains a URL. For example, "http://www.contoso.com:8080/letters/readme.html" returns "http:8080".

How to: Strip Invalid Characters from a String
Provides an example that strips invalid non-alphanumeric characters from a string.

How to: Verify that Strings Are in Valid Email Format
Provides an example that you can use to verify that a string is in valid email format.

Reference

xref:System.Text.RegularExpressions
Provides class library reference information for the .NET System.Text.RegularExpressions namespace.

Related Sections

.NET Regular Expressions
Provides an overview of the programming language aspect of regular expressions.

The Regular Expression Object Model
Describes the regular expression classes contained in the System.Text.RegularExpression namespace and provides examples of their use.

Details of Regular Expression Behavior
Provides information about the capabilities and behavior of .NET regular expressions.

Regular Expression Language - Quick Reference
Provides information on the set of characters, operators, and constructs that you can use to define regular expressions.