<!doctypehtml><html class="hasSidebar hasPageActions hasBreadcrumb conceptual has-default-focus theme-light"data-auth-status-determined=false data-authenticated=false data-css-variable-support=true data-target=docs dir=ltr lang=en-us x-ms-format-detection=none><meta charset=utf-8><meta content=width=device-width,initial-scale=1.0 name=viewport><meta content=".NET Regular Expressions"property=og:title><meta content=website property=og:type><meta content=https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions property=og:url><meta content="Use regular expressions to find specific character patterns, validate text, work with text substrings, & add extracted strings to a collection in .NET."property=og:description><meta content=https://docs.microsoft.com/dotnet/media/dot-net-cross-platform.png property=og:image><meta content=".NET Regular Expressions | Microsoft Docs"property=og:image:alt><meta content=summary name=twitter:card><meta content=@docsmsft name=twitter:site><meta content="light dark"name=color-scheme><meta content=dotnet name=apiPlatform><meta content=adegeo name=author><meta content=/dotnet/breadcrumb/toc.json name=breadcrumb_path><meta content=VS.core-docs name=depot_name><meta content="Use regular expressions to find specific character patterns, validate text, work with text substrings, & add extracted strings to a collection in .NET."name=description><meta content=2bd8ae60-9b02-3e9e-2318-982f563710c2 name=document_id><meta content=d167e261-eb1b-967b-5a6f-cbc2207cd32d name=document_version_independent_id><meta content=https://github.com/dotnet/docs/blob/4120c366a23aa625f82cfcee7e38fb84ae1d6940/docs/standard/base-types/regular-expressions.md name=gitcommit><meta content=en-us name=locale><meta content=521b3f6d-f869-42e1-93e5-158c54a6895d name=ms.assetid><meta content=adegeo name=ms.author><meta content=06/30/2020 name=ms.date><meta content=dotnet name=ms.devlang><meta content=dotnet-fundamentals name=ms.prod><meta content=conceptual name=ms.topic><meta content=https://github.com/dotnet/docs/blob/live/docs/standard/base-types/regular-expressions.md name=original_content_git_url><meta content=true name=recommendations><meta content=Conceptual name=schema><meta content=true name=show_latex><meta content=Docs name=site_name><meta content=MSDocsHeader-DotNet name=uhfHeaderId><meta content="2021-09-15 07:34 AM"name=updated_at><meta content=conceptual name=page_type><meta content=../../fundamentals/toc.json name=toc_rel><meta content=https://docs.microsoft.com/pdfstore/en-us/VS.core-docs/{branchName}{pdfName} name=pdf_url_template><meta content="csharp vb"name=search.mshattr.devlang><meta content=2110 name=word_count><meta content=.NET name=scope><link href=https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions rel=canonical><title>
   .NET Regular Expressions | Microsoft Docs
  </title><link href="/_themes/docs.theme/master/en-us/_themes/styles/46dad2a9.site-ltr.css "rel=stylesheet><script id=msdocs-script>var msDocs = {
		data: {
			timeOrigin: Date.now(),
			contentLocale: 'en-us',
			contentDir: 'ltr',
			userLocale: 'en-us',
			userDir: 'ltr',
			pageTemplate: 'Conceptual',
			brand: '',
			context: {

			},
			hasBinaryRating: true,
			hasGithubIssues: true,
			showFeedbackReport: false,
			enableTutorialFeedback: false,
			feedbackSystem: 'GitHub',
			feedbackGitHubRepo: 'dotnet/docs',
			feedbackProductUrl: 'https://aka.ms/feedback/report?space=61',
			contentGitUrl: 'https://github.com/dotnet/docs/blob/main/docs/standard/base-types/regular-expressions.md',
			extendBreadcrumb: false,
			isEditDisplayable: true,
			hideViewSource: false,
			hasPageActions: true,
			hasBookmark: true,
			hasShare: true,
			hasRecommendations: true,
			contributors: [
						{ name: "adegeo", url: "https://github.com/adegeo" },
						{ name: "tdykstra", url: "https://github.com/tdykstra" },
						{ name: "BillWagner", url: "https://github.com/BillWagner" },
						{ name: "gewarren", url: "https://github.com/gewarren" },
						{ name: "DennisLee-DennisLee", url: "https://github.com/DennisLee-DennisLee" },
						{ name: "mairaw", url: "https://github.com/mairaw" },
						{ name: "nschonni", url: "https://github.com/nschonni" },
						{ name: "ChrisMaddock", url: "https://github.com/ChrisMaddock" },
						{ name: "Mikejo5000", url: "https://github.com/Mikejo5000" },
						{ name: "mjhoffman65", url: "https://github.com/mjhoffman65" },
						{ name: "guardrex", url: "https://github.com/guardrex" },
						{ name: "yishengjin1413", url: "https://github.com/yishengjin1413" },
						{ name: "tompratt-AQ", url: "https://github.com/tompratt-AQ" },
						{ name: "stevehoag", url: "https://github.com/stevehoag" }
],
			mathjax: {
			},
		},
		functions:{}
	};</script><script src=https://wcpstatic.microsoft.com/mscc/lib/v2/wcp-consent.js></script><script src=https://js.monitor.azure.com/scripts/c/ms.jsll-3.min.js></script><script src=/_themes/docs.theme/master/en-us/_themes/global/5cce29c0.deprecation.js></script><script src=/_themes/docs.theme/master/en-us/_themes/scripts/bb2ae21c.index-docs.js></script><body dir=ltr lang=en-us><div class="header-holder has-default-focus"><a class="skip-to-main-link has-outline-color-text visually-hidden-until-focused position-fixed has-inner-focus focus-visible top-0 left-0 right-0 padding-xs has-text-centered has-body-background"href=#main tabindex=1> Skip to main content </a><div hidden id=cookie-consent-holder></div><div style="background-color: white;
			color: black;
			padding: 16px;
			border-bottom: 1px solid grey;"hidden id=unsupported-browser><div style="max-width: 800px; margin: 0 auto;"><p style="font-size: 24px">This browser is no longer supported.<p style="font-size: 16px; margin-top: 16px;">Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.<div style="margin-top: 12px;"><a href="https://go.microsoft.com/fwlink/p/?LinkID=2092881 "style="background-color: #0078d4;
						border: 1px solid #0078d4;
						color: white;
						padding: 6px 12px;
						border-radius: 2px;
						display: inline-block;"> Download Microsoft Edge </a><a style="background-color: white;
							padding: 6px 12px;
							border: 1px solid #505050;
							color: #171717;
							border-radius: 2px;
							display: inline-block;"href=https://docs.microsoft.com/en-US/lifecycle/faq/internet-explorer-microsoft-edge> More info </a></div></div></div><div data-bi-name=header id=headerAreaHolder><header itemscope itemtype=http://schema.org/Organization role=banner><div class=nav-bar><div class=nav-bar-brand><a aria-label=Microsoft class=nav-bar-button href=https://www.microsoft.com itemprop=url> <div class="nav-bar-logo has-background-image theme-display is-light"aria-hidden=true itemprop=logo itemscope role=presentation></div> <div class="nav-bar-logo has-background-image theme-display is-dark is-high-contrast"aria-hidden=true itemprop=logo itemscope role=presentation></div> </a></div></div><div class="nav-bar border-top is-hidden-mobile"></div></header></div><div class="content-header uhf-container has-padding has-default-focus border-bottom-none"data-bi-name=content-header><nav class="breadcrumb-holder has-padding-none has-padding-left-medium-tablet has-padding-right-medium-tablet has-padding-left-none-uhf-tablet has-padding-left-none-uhf-tablet has-padding-none-desktop flex-grow-1"aria-label=Breadcrumb data-bi-name=breadcrumb itemscope itemtype=http://schema.org/BreadcrumbList role=navigation><ul class=breadcrumbs id=page-breadcrumbs></ul></nav><div class=content-header-controls><button class="contents-button button"aria-haspopup=true data-bi-name=contents-expand type=button><span class=icon> <span class="docon docon-menu"aria-hidden=true> </span> </span> <span class=contents-expand-title> Contents </span></button><button class="ap-collapse-behavior ap-expanded button"aria-controls=action-panel data-bi-name=ap-collapse type=button><span class=icon> <span class="docon docon-exit-mode"aria-hidden=true> </span> </span> <span> Exit focus mode </span></button></div><div class="has-padding-none-tablet padding-xs font-size-sm display-flex justify-content-space-between flex-grow-1 page-action-holder"><ul class="is-hidden-mobile action-list justify-content-flex-start has-flex-justify-content-end-tablet display-flex flex-wrap-wrap flex-grow-1 is-unstyled"><li><div class="language dropdown has-caret is-inline-block border border-none-tablet"><button class="dropdown-trigger button button-clear button-sm"aria-controls=language-menu aria-expanded=false data-bi-name=language title=Language><span class="icon is-hidden-desktop margin-none"> <span class="docon docon-code-lang"aria-hidden=true> </span> </span> <span class="lang-title is-visually-hidden-touch align-self-flex-start is-hidden-portrait"dir=ltr> Language </span> <span class="icon is-hidden-mobile is-hidden-tablet-only"aria-hidden=true> <span class="docon docon-chevron-down-light expanded-indicator"> </span> </span></button><div class="dropdown-menu has-padding-small language-selector"name=language-selector role=menu><ul data-bi-name=language-links dir=ltr><li><a class="button button-clear button-sm button-block"aria-selected=false data-bi-name=lang-csharp tabindex=0> </a><li><a class="button button-clear button-sm button-block"aria-selected=false data-bi-name=lang-vb tabindex=0> </a></ul></div></div><li hidden><a class="button button button-clear button-sm"title="Read in English"data-bi-name=language-toggle id=lang-link> <span class="icon docon docon-locale-globe"aria-hidden=true id=lang-link-icon> </span> <span class="is-visually-hidden-touch is-hidden-portrait"id=lang-link-text> </span> </a><li><button class="collection button button-clear button-sm has-inner-focus"title="Add to collection"data-bi-name=collection data-list-type=collection type=button><span aria-hidden=true class=icon> <span class="docon docon-circle-addition has-text-primary"> </span> </span> <span class="collection-status is-visually-hidden-touch is-hidden-portrait"> Save </span></button><li id=feedback-section-link><a class="button button button-clear button-sm has-inner-focus"title="Send feedback about this page"data-bi-name=comments href=#feedback> <span aria-hidden=true class=icon> <span class="docon docon-comment-lines"> </span> </span> <span class="is-visually-hidden-touch is-hidden-portrait"> Feedback </span> </a><li id=contenteditbtn><a class="button button-clear button-sm has-inner-focus"title="Edit This Document"data-bi-name=edit data-original_content_git_url=https://github.com/dotnet/docs/blob/live/docs/standard/base-types/regular-expressions.md data-original_content_git_url_template={repo}/blob/{branch}/docs/standard/base-types/regular-expressions.md data-pr_branch data-pr_repo href=https://github.com/dotnet/docs/blob/main/docs/standard/base-types/regular-expressions.md> <span aria-hidden=true class=icon> <span class="docon docon-edit-outline"> </span> </span> <span class="is-visually-hidden-touch is-hidden-portrait"> Edit </span> </a><li><div class="sharing dropdown has-caret"><button class="dropdown-trigger button button-clear button-sm button-block justify-content-flex-start has-inner-focus"title="Share This Document"aria-controls=sharing-menu aria-expanded=false data-bi-name=share><span aria-hidden=true class=icon> <span class="docon docon-sharing"> </span> </span> <span class="is-visually-hidden-touch is-hidden-portrait"> Share </span></button><div class="dropdown-menu has-padding-small"id=sharing-menu><ul data-bi-name=share-links><li><a class="button button-clear button-sm button-block justify-content-flex-start has-inner-focus share-twitter"data-bi-name=twitter> <span class=icon> <span class="docon docon-brand-twitter has-text-primary"aria-hidden=true> </span> </span> <span> Twitter </span> </a><li><a class="button button-clear button-sm button-block justify-content-flex-start has-inner-focus share-linkedin"data-bi-name=linkedin> <span class=icon> <span class="docon docon-brand-linkedin has-text-primary"aria-hidden=true> </span> </span> <span> LinkedIn </span> </a><li><a class="button button-clear button-sm button-block justify-content-flex-start has-inner-focus share-facebook"data-bi-name=facebook> <span class=icon> <span class="docon docon-brand-facebook has-text-primary"aria-hidden=true> </span> </span> <span> Facebook </span> </a><li><a class="button button-clear button-sm button-block justify-content-flex-start has-inner-focus share-email"data-bi-name=email> <span class=icon> <span class="docon docon-mail-message-fill has-text-primary"aria-hidden=true> </span> </span> <span> Email </span> </a></ul></div></div></ul><button class="border contents-button button button-clear button-sm is-hidden-tablet has-inner-focus"aria-label=Contents data-bi-name=contents-expand type=button><span class=icon> <span class="docon docon-editor-list-bullet"aria-hidden=true> </span> </span> <span class=contents-expand-title> Table of contents </span></button><div class=is-invisible></div><div class="is-hidden-tablet level-item is-flexible level-right"><div class="language dropdown has-caret is-inline-block border border-none-tablet"><button class="dropdown-trigger button button-clear button-sm"aria-controls=language-menu aria-expanded=false data-bi-name=language title=Language><span class="icon is-hidden-desktop margin-none"> <span class="docon docon-code-lang"aria-hidden=true> </span> </span> <span class="lang-title is-visually-hidden-touch align-self-flex-start is-hidden-portrait"dir=ltr> Language </span> <span class="icon is-hidden-mobile is-hidden-tablet-only"aria-hidden=true> <span class="docon docon-chevron-down-light expanded-indicator"> </span> </span></button><div class="dropdown-menu has-padding-small language-selector"name=language-selector role=menu><ul data-bi-name=language-links dir=ltr><li><a class="button button-clear button-sm button-block"aria-selected=false data-bi-name=lang-csharp tabindex=0> </a><li><a class="button button-clear button-sm button-block"aria-selected=false data-bi-name=lang-vb tabindex=0> </a></ul></div></div><button aria-label="Page Actions"class="page-actions-button button button-clear button-sm is-hidden-tablet has-inner-focus border is-full-height has-margin-left-small"data-bi-name=pageactions type=button><span class=icon> <span class="docon docon-more-vertical"aria-hidden=true> </span> </span></button></div></div></div><div class="has-overflow-hidden has-default-focus"id=disclaimer-holder></div></div><div class="mainContainer uhf-container has-top-padding has-default-focus"data-bi-name=body><div class="columns has-large-gaps is-gapless-mobile"><div class="left-container is-hidden-mobile column is-one-third-tablet is-one-quarter-desktop"id=left-container><nav class="position-fixed display-flex flex-direction-column"aria-label=Primary id=affixed-left-container role=navigation></nav></div><section class="primary-holder column is-two-thirds-tablet is-three-quarters-desktop"><div class="columns is-gapless-mobile has-large-gaps"><div class="column is-full is-8-desktop"id=main-column><main class=content data-bi-name=content dir=ltr id=main lang=en-us role=main><h1 id=net-regular-expressions>.NET regular expressions</h1><ul class="metadata page-metadata"data-bi-name="page info"dir=ltr lang=en-us><li><time aria-label="Article review date"class=is-invisible data-article-date data-article-date-source=git datetime=2021-09-15T07:34:00Z> 09/15/2021 </time><li class=readingTime>10 minutes to read<li class=contributors-holder><ul class="facepile has-margin-left-none is-small"data-bi-name=contributors><li class=facepile-item><a aria-label="adegeoGithub profile"class=facepile-item-coin data-contributor-name=adegeo data-src=https://github.com/adegeo.png?size=32 href=https://github.com/adegeo title=adegeo> <img class="facepile-item-coin-image durable-image"onerror="this.className='facepile-item-coin-image durable-image has-error';"aria-hidden=true role=presentation src=https://github.com/adegeo.png?size=32> <span class="facepile-item-coin-text durable-image-fallback facepile-item-teal"aria-hidden=true> a </span> </a><li class=facepile-item><a aria-label="tdykstraGithub profile"class=facepile-item-coin data-contributor-name=tdykstra data-src=https://github.com/tdykstra.png?size=32 href=https://github.com/tdykstra title=tdykstra> <img class="facepile-item-coin-image durable-image"onerror="this.className='facepile-item-coin-image durable-image has-error';"aria-hidden=true role=presentation src=https://github.com/tdykstra.png?size=32> <span class="facepile-item-coin-text durable-image-fallback facepile-item-red"aria-hidden=true> t </span> </a><li class=facepile-item><a aria-label="BillWagnerGithub profile"class=facepile-item-coin data-contributor-name=BillWagner data-src=https://github.com/BillWagner.png?size=32 href=https://github.com/BillWagner title=BillWagner> <img class="facepile-item-coin-image durable-image"onerror="this.className='facepile-item-coin-image durable-image has-error';"aria-hidden=true role=presentation src=https://github.com/BillWagner.png?size=32> <span class="facepile-item-coin-text durable-image-fallback facepile-item-blue"aria-hidden=true> B </span> </a><li class=facepile-item><a aria-label="gewarrenGithub profile"class=facepile-item-coin data-contributor-name=gewarren data-src=https://github.com/gewarren.png?size=32 href=https://github.com/gewarren title=gewarren> <img class="facepile-item-coin-image durable-image"onerror="this.className='facepile-item-coin-image durable-image has-error';"aria-hidden=true role=presentation src=https://github.com/gewarren.png?size=32> <span class="facepile-item-coin-text durable-image-fallback facepile-item-teal"aria-hidden=true> g </span> </a><li class=facepile-item><a aria-label="DennisLee-DennisLeeGithub profile"class=facepile-item-coin data-contributor-name=DennisLee-DennisLee data-src=https://github.com/DennisLee-DennisLee.png?size=32 href=https://github.com/DennisLee-DennisLee title=DennisLee-DennisLee> <img class="facepile-item-coin-image durable-image"onerror="this.className='facepile-item-coin-image durable-image has-error';"aria-hidden=true role=presentation src=https://github.com/DennisLee-DennisLee.png?size=32> <span class="facepile-item-coin-text durable-image-fallback facepile-item-red"aria-hidden=true> D </span> </a><li class=facepile-item><button aria-label="View all contributors"title="View all contributors"class=facepile-item-more><div aria-hidden=true class=facepile-item-coin><span aria-hidden=true class=facepile-item-coin-text> +9 </span></div></button></ul></ul><nav aria-label="Article Outline"class="doc-outline is-hidden-desktop"data-bi-name="intopic toc"id=center-doc-outline role=navigation><h3>In this article</h3></nav><p>Regular expressions provide a powerful, flexible, and efficient method for processing text. The extensive pattern-matching notation of regular expressions enables you to quickly parse large amounts of text to:<ul><li>Find specific character patterns.<li>Validate text to ensure that it matches a predefined pattern (such as an email address).<li>Extract, edit, replace, or delete text substrings.<li>Add extracted strings to a collection in order to generate a report.</ul><p>For many applications that deal with strings or that parse large blocks of text, regular expressions are an indispensable tool.<h2 id=how-regular-expressions-work>How regular expressions work</h2><p>The centerpiece of text processing with regular expressions is the regular expression engine, which is represented by the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex> System.Text.RegularExpressions.Regex </a> object in .NET. At a minimum, processing text using regular expressions requires that the regular expression engine be provided with the following two items of information:<ul><li><p>The regular expression pattern to identify in the text.</p> <p>In .NET, regular expression patterns are defined by a special syntax or language, which is compatible with Perl 5 regular expressions and adds some additional features such as right-to-left matching. For more information, see <a data-linktype=relative-path href=regular-expression-language-quick-reference> Regular Expression Language - Quick Reference </a> .</p><li><p>The text to parse for the regular expression pattern.</p></ul><p>The methods of the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex> Regex </a> class let you perform the following operations:<ul><li><p>Determine whether the regular expression pattern occurs in the input text by calling the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch> Regex.IsMatch </a> method. For an example that uses the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch> IsMatch </a> method for validating text, see <a data-linktype=relative-path href=how-to-verify-that-strings-are-in-valid-email-format> How to: Verify that Strings Are in Valid Email Format </a> .</p><li><p>Retrieve one or all occurrences of text that matches the regular expression pattern by calling the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.match> Regex.Match </a> or <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.matches> Regex.Matches </a> method. The former method returns a <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.match> System.Text.RegularExpressions.Match </a> object that provides information about the matching text. The latter returns a <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.matchcollection> MatchCollection </a> object that contains one <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.match> System.Text.RegularExpressions.Match </a> object for each match found in the parsed text.</p><li><p>Replace text that matches the regular expression pattern by calling the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.replace> Regex.Replace </a> method. For examples that use the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.replace> Replace </a> method to change date formats and remove invalid characters from a string, see <a data-linktype=relative-path href=how-to-strip-invalid-characters-from-a-string> How to: Strip Invalid Characters from a String </a> and <a data-linktype=relative-path href=regular-expression-example-changing-date-formats> Example: Changing Date Formats </a> .</p></ul><p>For an overview of the regular expression object model, see <a data-linktype=relative-path href=the-regular-expression-object-model> The Regular Expression Object Model </a> .<p>For more information about the regular expression language, see <a data-linktype=relative-path href=regular-expression-language-quick-reference> Regular Expression Language - Quick Reference </a> or download and print one of these brochures:<ul><li><a data-linktype=external href=https://download.microsoft.com/download/D/2/4/D240EBF6-A9BA-4E4F-A63F-AEB6DA0B921C/Regular%20expressions%20quick%20reference.docx> Quick Reference in Word (.docx) format </a><li><a data-linktype=external href=https://download.microsoft.com/download/D/2/4/D240EBF6-A9BA-4E4F-A63F-AEB6DA0B921C/Regular%20expressions%20quick%20reference.pdf> Quick Reference in PDF (.pdf) format </a></ul><h2 id=regular-expression-examples>Regular expression examples</h2><p>The <a data-linktype=absolute-path href=/en-us/dotnet/api/system.string> String </a> class includes a number of string search and replacement methods that you can use when you want to locate literal strings in a larger string. Regular expressions are most useful either when you want to locate one of several substrings in a larger string, or when you want to identify patterns in a string, as the following examples illustrate.<div class=WARNING><p>Warning<p>When using <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions> System.Text.RegularExpressions </a> to process untrusted input, pass a timeout. A malicious user can provide input to <code>
           RegularExpressions
          </code> causing a <a data-linktype=external href=https://www.us-cert.gov/ncas/tips/ST04-015> Denial-of-Service attack </a> . ASP.NET Core framework APIs that use <code>
           RegularExpressions
          </code> pass a timeout.</div><div class=TIP><p>Tip<p>The <a data-linktype=absolute-path href=/en-us/dotnet/api/system.web.regularexpressions> System.Web.RegularExpressions </a> 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 <a data-linktype=absolute-path href=/en-us/dotnet/api/system.web.regularexpressions.tagregex> TagRegex </a> class identifies start tags in a string and the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.web.regularexpressions.commentregex> CommentRegex </a> class identifies ASP.NET comments in a string.</div><h3 id=example-1-replace-substrings>Example 1: Replace substrings</h3><p>Assume that a mailing list contains names that sometimes include a title (Mr., Mrs., Miss, or Ms.) along with a first and last name. If you do not want to include the titles when you generate envelope labels from the list, you can use a regular expression to remove the titles, as the following example illustrates.<pre><code class=lang-csharp name=Conceptual.Regex#2>using System;
using System.Text.RegularExpressions;

public class Example
{
   public static void Main()
   {
      string pattern = "(Mr\\.? |Mrs\\.? |Miss |Ms\\.? )";
      string[] names = { "Mr. Henry Hunt", "Ms. Sara Samuels",
                         "Abraham Adams", "Ms. Nicole Norris" };
      foreach (string name in names)
         Console.WriteLine(Regex.Replace(name, pattern, String.Empty));
   }
}
// The example displays the following output:
//    Henry Hunt
//    Sara Samuels
//    Abraham Adams
//    Nicole Norris
</code></pre><pre><code class=lang-vb name=Conceptual.Regex#2>Imports System.Text.RegularExpressions

Module Example
    Public Sub Main()
        Dim pattern As String = "(Mr\.? |Mrs\.? |Miss |Ms\.? )"
        Dim names() As String = {"Mr. Henry Hunt", "Ms. Sara Samuels", _
                                  "Abraham Adams", "Ms. Nicole Norris"}
        For Each name As String In names
            Console.WriteLine(Regex.Replace(name, pattern, String.Empty))
        Next
    End Sub
End Module
' The example displays the following output:
'    Henry Hunt
'    Sara Samuels
'    Abraham Adams
'    Nicole Norris
</code></pre><p>The regular expression pattern <code>
          (Mr\.? |Mrs\.? |Miss |Ms\.? )
         </code> matches any occurrence of "Mr ", "Mr. ", "Mrs ", "Mrs. ", "Miss ", "Ms or "Ms. ". The call to the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.replace> Regex.Replace </a> method replaces the matched string with <a data-linktype=absolute-path href=/en-us/dotnet/api/system.string.empty> String.Empty </a> ; in other words, it removes it from the original string.<h3 id=example-2-identify-duplicated-words>Example 2: Identify duplicated words</h3><p>Accidentally duplicating words is a common error that writers make. A regular expression can be used to identify duplicated words, as the following example shows.<pre><code class=lang-csharp name=Conceptual.Regex#3>using System;
using System.Text.RegularExpressions;

public class Class1
{
   public static void Main()
   {
      string pattern = @"\b(\w+?)\s\1\b";
      string input = "This this is a nice day. What about this? This tastes good. I saw a a dog.";
      foreach (Match match in Regex.Matches(input, pattern, RegexOptions.IgnoreCase))
         Console.WriteLine("{0} (duplicates '{1}') at position {2}",
                           match.Value, match.Groups[1].Value, match.Index);
   }
}
// The example displays the following output:
//       This this (duplicates 'This') at position 0
//       a a (duplicates 'a') at position 66
</code></pre><pre><code class=lang-vb name=Conceptual.Regex#3>Imports System.Text.RegularExpressions

Module modMain
    Public Sub Main()
        Dim pattern As String = "\b(\w+?)\s\1\b"
        Dim input As String = "This this is a nice day. What about this? This tastes good. I saw a a dog."
        For Each match As Match In Regex.Matches(input, pattern, RegexOptions.IgnoreCase)
            Console.WriteLine("{0} (duplicates '{1}') at position {2}", _
                              match.Value, match.Groups(1).Value, match.Index)
        Next
    End Sub
End Module
' The example displays the following output:
'       This this (duplicates 'This') at position 0
'       a a (duplicates 'a') at position 66
</code></pre><p>The regular expression pattern <code>
          \b(\w+?)\s\1\b
         </code> can be interpreted as follows:<div class=mx-tdCol2BreakAll><table><thead><tr><th>Pattern<th>Interpretation<tbody><tr><td><code>
              \b
             </code><td>Start at a word boundary.<tr><td><code>
              (\w+?)
             </code><td>Match one or more word characters, but as few characters as possible. Together, they form a group that can be referred to as <code>
              \1
             </code> .<tr><td><code>
              \s
             </code><td>Match a white-space character.<tr><td><code>
              \1
             </code><td>Match the substring that is equal to the group named <code>
              \1
             </code> .<tr><td><code>
              \b
             </code><td>Match a word boundary.</table></div><p>The <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.matches> Regex.Matches </a> method is called with regular expression options set to <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regexoptions#System_Text_RegularExpressions_RegexOptions_IgnoreCase> RegexOptions.IgnoreCase </a> . Therefore, the match operation is case-insensitive, and the example identifies the substring "This this" as a duplication.<p>The input string includes the substring "this? This". However, because of the intervening punctuation mark, it is not identified as a duplication.<h3 id=example-3-dynamically-build-a-culture-sensitive-regular-expression>Example 3: Dynamically build a culture-sensitive regular expression</h3><p>The following example illustrates the power of regular expressions combined with the flexibility offered by .NET's globalization features. It uses the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.globalization.numberformatinfo> NumberFormatInfo </a> object to determine the format of currency values in the system's current culture. It then uses that information to dynamically construct a regular expression that extracts currency values from the text. For each match, it extracts the subgroup that contains the numeric string only, converts it to a <a data-linktype=absolute-path href=/en-us/dotnet/api/system.decimal> Decimal </a> value, and calculates a running total.<pre><code class=lang-csharp name=Conceptual.Regex#1>using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;

public class Example
{
   public static void Main()
   {
      // Define text to be parsed.
      string input = "Office expenses on 2/13/2008:\n" +
                     "Paper (500 sheets)                      $3.95\n" +
                     "Pencils (box of 10)                     $1.00\n" +
                     "Pens (box of 10)                        $4.49\n" +
                     "Erasers                                 $2.19\n" +
                     "Ink jet printer                        $69.95\n\n" +
                     "Total Expenses                        $ 81.58\n";

      // Get current culture's NumberFormatInfo object.
      NumberFormatInfo nfi = CultureInfo.CurrentCulture.NumberFormat;
      // Assign needed property values to variables.
      string currencySymbol = nfi.CurrencySymbol;
      bool symbolPrecedesIfPositive = nfi.CurrencyPositivePattern % 2 == 0;
      string groupSeparator = nfi.CurrencyGroupSeparator;
      string decimalSeparator = nfi.CurrencyDecimalSeparator;

      // Form regular expression pattern.
      string pattern = Regex.Escape( symbolPrecedesIfPositive ? currencySymbol : "") +
                       @"\s*[-+]?" + "([0-9]{0,3}(" + groupSeparator + "[0-9]{3})*(" +
                       Regex.Escape(decimalSeparator) + "[0-9]+)?)" +
                       (! symbolPrecedesIfPositive ? currencySymbol : "");
      Console.WriteLine( "The regular expression pattern is:");
      Console.WriteLine("   " + pattern);

      // Get text that matches regular expression pattern.
      MatchCollection matches = Regex.Matches(input, pattern,
                                              RegexOptions.IgnorePatternWhitespace);
      Console.WriteLine("Found {0} matches.", matches.Count);

      // Get numeric string, convert it to a value, and add it to List object.
      List&LTdecimal> expenses = new List&LTDecimal>();

      foreach (Match match in matches)
         expenses.Add(Decimal.Parse(match.Groups[1].Value));

      // Determine whether total is present and if present, whether it is correct.
      decimal total = 0;
      foreach (decimal value in expenses)
         total += value;

      if (total / 2 == expenses[expenses.Count - 1])
         Console.WriteLine("The expenses total {0:C2}.", expenses[expenses.Count - 1]);
      else
         Console.WriteLine("The expenses total {0:C2}.", total);
   }
}
// The example displays the following output:
//       The regular expression pattern is:
//          \$\s*[-+]?([0-9]{0,3}(,[0-9]{3})*(\.[0-9]+)?)
//       Found 6 matches.
//       The expenses total $81.58.
</code></pre><pre><code class=lang-vb name=Conceptual.Regex#1>Imports System.Collections.Generic
Imports System.Globalization
Imports System.Text.RegularExpressions

Public Module Example
    Public Sub Main()
        ' Define text to be parsed.
        Dim input As String = "Office expenses on 2/13/2008:" + vbCrLf + _
                              "Paper (500 sheets)                      $3.95" + vbCrLf + _
                              "Pencils (box of 10)                     $1.00" + vbCrLf + _
                              "Pens (box of 10)                        $4.49" + vbCrLf + _
                              "Erasers                                 $2.19" + vbCrLf + _
                              "Ink jet printer                        $69.95" + vbCrLf + vbCrLf + _
                              "Total Expenses                        $ 81.58" + vbCrLf
        ' Get current culture's NumberFormatInfo object.
        Dim nfi As NumberFormatInfo = CultureInfo.CurrentCulture.NumberFormat
        ' Assign needed property values to variables.
        Dim currencySymbol As String = nfi.CurrencySymbol
        Dim symbolPrecedesIfPositive As Boolean = CBool(nfi.CurrencyPositivePattern Mod 2 = 0)
        Dim groupSeparator As String = nfi.CurrencyGroupSeparator
        Dim decimalSeparator As String = nfi.CurrencyDecimalSeparator

        ' Form regular expression pattern.
        Dim pattern As String = Regex.Escape(CStr(IIf(symbolPrecedesIfPositive, currencySymbol, ""))) + _
                                "\s*[-+]?" + "([0-9]{0,3}(" + groupSeparator + "[0-9]{3})*(" + _
                                Regex.Escape(decimalSeparator) + "[0-9]+)?)" + _
                                CStr(IIf(Not symbolPrecedesIfPositive, currencySymbol, ""))
        Console.WriteLine("The regular expression pattern is: ")
        Console.WriteLine("   " + pattern)

        ' Get text that matches regular expression pattern.
        Dim matches As MatchCollection = Regex.Matches(input, pattern, RegexOptions.IgnorePatternWhitespace)
        Console.WriteLine("Found {0} matches. ", matches.Count)

        ' Get numeric string, convert it to a value, and add it to List object.
        Dim expenses As New List(Of Decimal)

        For Each match As Match In matches
            expenses.Add(Decimal.Parse(match.Groups.Item(1).Value))
        Next

        ' Determine whether total is present and if present, whether it is correct.
        Dim total As Decimal
        For Each value As Decimal In expenses
            total += value
        Next

        If total / 2 = expenses(expenses.Count - 1) Then
            Console.WriteLine("The expenses total {0:C2}.", expenses(expenses.Count - 1))
        Else
            Console.WriteLine("The expenses total {0:C2}.", total)
        End If
    End Sub
End Module
' The example displays the following output:
'       The regular expression pattern is:
'          \$\s*[-+]?([0-9]{0,3}(,[0-9]{3})*(\.[0-9]+)?)
'       Found 6 matches.
'       The expenses total $81.58.
</code></pre><p>On a computer whose current culture is English - United States (en-US), the example dynamically builds the regular expression <code>
          \$\s*[-+]?([0-9]{0,3}(,[0-9]{3})*(\.[0-9]+)?)
         </code> . This regular expression pattern can be interpreted as follows:<div class=mx-tdCol2BreakAll><table><thead><tr><th>Pattern<th>Interpretation<tbody><tr><td><code>
              \$
             </code><td>Look for a single occurrence of the dollar symbol ( <code>
              $
             </code> ) in the input string. The regular expression pattern string includes a backslash to indicate that the dollar symbol is to be interpreted literally rather than as a regular expression anchor. (The <code>
              $
             </code> symbol alone would indicate that the regular expression engine should try to begin its match at the end of a string.) To ensure that the current culture's currency symbol is not misinterpreted as a regular expression symbol, the example calls the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex.escape> Regex.Escape </a> method to escape the character.<tr><td><code>
              \s*
             </code><td>Look for zero or more occurrences of a white-space character.<tr><td><code>
              [-+]?
             </code><td>Look for zero or one occurrence of either a positive sign or a negative sign.<tr><td><code>
              ([0-9]{0,3}(,[0-9]{3})*(\.[0-9]+)?)
             </code><td>The outer parentheses around this expression define it as a capturing group or a subexpression. If a match is found, information about this part of the matching string can be retrieved from the second <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.group> Group </a> object in the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.groupcollection> GroupCollection </a> object returned by the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.match.groups> Match.Groups </a> property. (The first element in the collection represents the entire match.)<tr><td><code>
              [0-9]{0,3}
             </code><td>Look for zero to three occurrences of the decimal digits 0 through 9.<tr><td><code>
              (,[0-9]{3})*
             </code><td>Look for zero or more occurrences of a group separator followed by three decimal digits.<tr><td><code>
              \.
             </code><td>Look for a single occurrence of the decimal separator.<tr><td><code>
              [0-9]+
             </code><td>Look for one or more decimal digits.<tr><td><code>
              (\.[0-9]+)?
             </code><td>Look for zero or one occurrence of the decimal separator followed by at least one decimal digit.</table></div><p>If each of these subpatterns is found in the input string, the match succeeds, and a <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.match> Match </a> object that contains information about the match is added to the <a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.matchcollection> MatchCollection </a> object.<h2 id=related-topics>Related topics</h2><table><thead><tr><th>Title<th>Description<tbody><tr><td><a data-linktype=relative-path href=regular-expression-language-quick-reference> Regular Expression Language - Quick Reference </a><td>Provides information on the set of characters, operators, and constructs that you can use to define regular expressions.<tr><td><a data-linktype=relative-path href=the-regular-expression-object-model> The Regular Expression Object Model </a><td>Provides information and code examples that illustrate how to use the regular expression classes.<tr><td><a data-linktype=relative-path href=details-of-regular-expression-behavior> Details of Regular Expression Behavior </a><td>Provides information about the capabilities and behavior of .NET regular expressions.<tr><td><a data-linktype=absolute-path href=/en-us/visualstudio/ide/using-regular-expressions-in-visual-studio> Use regular expressions in Visual Studio </a><td></table><h2 id=reference>Reference</h2><ul><li><a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions> System.Text.RegularExpressions </a><li><a data-linktype=absolute-path href=/en-us/dotnet/api/system.text.regularexpressions.regex> System.Text.RegularExpressions.Regex </a><li><a data-linktype=external href=https://download.microsoft.com/download/D/2/4/D240EBF6-A9BA-4E4F-A63F-AEB6DA0B921C/Regular%20expressions%20quick%20reference.docx> Regular Expressions - Quick Reference (download in Word format) </a><li><a data-linktype=external href=https://download.microsoft.com/download/D/2/4/D240EBF6-A9BA-4E4F-A63F-AEB6DA0B921C/Regular%20expressions%20quick%20reference.pdf> Regular Expressions - Quick Reference (download in PDF format) </a></ul></main><div class="is-hidden-desktop border-top has-margin-top-large has-padding-top-large binary-rating-holder"><div class="feedback-verbatim border-bottom has-padding-bottom-large has-margin-bottom-small"data-bi-name=rating><div class=binary-rating><div class=binary-rating-buttons><h3 class="font-weight-semibold has-margin-top-none font-size-h4 margin-bottom-xs">Is this page helpful?</h3><div><button class="thumb-rating like has-inner-focus"aria-controls=rating-container-desktop aria-expanded=false data-bi-name=rating-yes data-bi-sat=1 title=Yes><span class="icon docon docon-like"aria-hidden=true> </span> <span> Yes </span></button><button class="thumb-rating dislike has-inner-focus"aria-controls=rating-container-desktop aria-expanded=false data-bi-name=rating-no data-bi-sat=0 title=No><span class="icon docon docon-dislike"aria-hidden=true> </span> <span> No </span></button></div></div><form class="feedback-verbatim-form is-hidden"id=rating-container-desktop><div class="verbatim-textarea box position-relative box-shadow-none border has-margin-top-small has-padding-extra-small font-size-xs"><label class=visually-hidden for=rating-textarea-desktop>Any additional feedback?</label><textarea class="textarea border-none box-shadow-none has-inner-focus"placeholder="Any additional feedback?"id=rating-textarea-desktop maxlength=999 required rows=4></textarea></div><p class="font-size-xs has-line-height-reset">Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services. <a href=https://privacy.microsoft.com/en-us/privacystatement> Privacy policy. </a><div class="buttons buttons-right margin-top-xs has-margin-right-extra-small"><button class="skip-rating button button-clear button-primary button-sm"type=button>Skip</button><button class="submit-rating button button-primary button-filled button-sm"data-bi-name=rating-verbatim disabled>Submit</button></div></form></div><div class="thankyou-rating is-hidden"tabindex=-1><p>Thank you.</div></div></div><section data-bi-name=recommendations id=recommendations-section></section><section class="feedback-section position-relative"data-bi-name=feedback-section><h2 class="title is-3 has-margin-top-large"id=feedback>Feedback</h2><div class="alert choose-feedback-type"><p aria-hidden=true id=send-feedback-about>Submit and view feedback for<div class="choose-feedback-buttons margin-top-xs"><a aria-label="Send feedback about this product"class="button has-external-link-indicator feedback-type-product has-margin-bottom-small"data-bi-name=product-feedback href=https://aka.ms/feedback/report?space=61> <span> This product </span> </a><a aria-label="Send feedback about this page"class="button feedback-type-product has-margin-bottom-small github-link"data-bi-name=create-issue-on-github> <span class="docon docon-brand-github has-padding-right-extra-small"aria-hidden=true> </span> <span> This page </span> </a></div></div><div class="action-container display-flex justify-content-flex-end has-margin-top-small has-margin-bottom-small"><a class="view-on-github has-external-link-indicator"data-bi-name=view-on-github href=https://github.com/dotnet/docs/issues> <span class="docon docon-brand-github"aria-hidden=true> </span> <span> View all page feedback </span> </a></div></section><div class="border-top is-visible-interactive has-default-focus has-margin-top-large"><footer class=footer-layout data-bi-name=footer id=footer-interactive><div class="display-flex is-full-height has-padding-right-extra-large-desktop"><a class="locale-selector-link button button-clear flex-shrink-0"data-bi-name=select-locale data-mscc-ic=false href=#> <span aria-hidden=true class=icon> <span class="docon docon-world"> </span> </span> <span class=local-selector-link-text> </span> </a><div class="margin-inline-xs flex-shrink-0"><div class="dropdown has-caret-up"><button class="dropdown-trigger button button-clear button-sm has-inner-focus theme-dropdown-trigger"aria-controls=theme-menu-interactive aria-expanded=false data-bi-name=theme title=Theme><span class=icon> <span class="docon docon-sun"aria-hidden=true> </span> </span> <span> Theme </span></button><div class=dropdown-menu id=theme-menu-interactive role=menu><ul class="theme-selector has-padding-small"><li class="theme is-block"><button class="button button-clear button-sm theme-control button-block justify-content-flex-start"data-theme-to=light><span class="theme-light has-margin-right-small"> <span class="theme-selector-icon css-variable-support border is-inline-block has-body-background"aria-hidden=true> <svg viewbox="0 0 22 14"class=svg xmlns=http://www.w3.org/2000/svg><rect class=has-fill-body-background height=14 width=22></rect><rect class=has-fill-secondary height=4 width=12 x=5 y=5></rect><rect class=has-fill-secondary height=1 width=2 x=5 y=2></rect><rect class=has-fill-secondary height=1 width=2 x=8 y=2></rect><rect class=has-fill-secondary height=1 width=3 x=11 y=2></rect><rect class=has-fill-secondary height=2 width=2 x=1 y=1></rect><rect class=has-fill-primary height=2 rx=0.3 width=7 x=5 y=10></rect><rect class=has-fill-secondary height=2 rx=1 width=2 x=19 y=1></rect></svg> </span> </span> <span role=menuitem> Light </span></button><li class="theme is-block"><button class="button button-clear button-sm theme-control button-block justify-content-flex-start"data-theme-to=dark><span class="theme-dark has-margin-right-small"> <span class="border theme-selector-icon css-variable-support is-inline-block has-body-background"aria-hidden=true> <svg viewbox="0 0 22 14"class=svg xmlns=http://www.w3.org/2000/svg><rect class=has-fill-body-background height=14 width=22></rect><rect class=has-fill-secondary height=4 width=12 x=5 y=5></rect><rect class=has-fill-secondary height=1 width=2 x=5 y=2></rect><rect class=has-fill-secondary height=1 width=2 x=8 y=2></rect><rect class=has-fill-secondary height=1 width=3 x=11 y=2></rect><rect class=has-fill-secondary height=2 width=2 x=1 y=1></rect><rect class=has-fill-primary height=2 rx=0.3 width=7 x=5 y=10></rect><rect class=has-fill-secondary height=2 rx=1 width=2 x=19 y=1></rect></svg> </span> </span> <span role=menuitem> Dark </span></button><li class="theme is-block"><button class="button button-clear button-sm theme-control button-block justify-content-flex-start"data-theme-to=high-contrast><span class="theme-high-contrast has-margin-right-small"> <span class="border theme-selector-icon css-variable-support is-inline-block has-body-background"aria-hidden=true> <svg viewbox="0 0 22 14"class=svg xmlns=http://www.w3.org/2000/svg><rect class=has-fill-body-background height=14 width=22></rect><rect class=has-fill-secondary height=4 width=12 x=5 y=5></rect><rect class=has-fill-secondary height=1 width=2 x=5 y=2></rect><rect class=has-fill-secondary height=1 width=2 x=8 y=2></rect><rect class=has-fill-secondary height=1 width=3 x=11 y=2></rect><rect class=has-fill-secondary height=2 width=2 x=1 y=1></rect><rect class=has-fill-primary height=2 rx=0.3 width=7 x=5 y=10></rect><rect class=has-fill-secondary height=2 rx=1 width=2 x=19 y=1></rect></svg> </span> </span> <span role=menuitem> High contrast </span></button></ul></div></div></div></div><ul class=links data-bi-name=footerlinks><li class=manage-cookies-holder hidden><li><a data-bi-name=archivelink data-mscc-ic=false href=https://docs.microsoft.com/en-us/previous-versions/> Previous Version Docs </a><li><a data-bi-name=bloglink data-mscc-ic=false href=https://docs.microsoft.com/en-us/teamblog> Blog </a><li><a data-bi-name=contributorGuide data-mscc-ic=false href=https://docs.microsoft.com/en-us/contribute> Contribute </a><li><a data-bi-name=privacy data-mscc-ic=false href=https://go.microsoft.com/fwlink/?LinkId=521839> Privacy & Cookies </a><li><a data-bi-name=termsofuse data-mscc-ic=false href=https://docs.microsoft.com/en-us/legal/termsofuse> Terms of Use </a><li><a data-bi-name=trademarks data-mscc-ic=false href=https://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/EN-US.aspx> Trademarks </a><li>© Microsoft 2021</ul></footer></div></div><div aria-label="Page Actions"class="font-size-sm right-container column is-4-desktop display-none display-block-desktop"data-bi-name=pageactions role=complementary><div class="doc-outline is-vertically-scrollable"id=affixed-right-container><div class="feedback-verbatim border-bottom has-padding-bottom-small has-margin-bottom-small"data-bi-name=rating><div class=binary-rating><div class=binary-rating-buttons><h3 class="font-weight-semibold has-margin-top-none has-margin-bottom-small">Is this page helpful?</h3><div><button class="thumb-rating like has-inner-focus"aria-controls=rating-container-mobile aria-expanded=false data-bi-name=rating-yes data-bi-sat=1 title=Yes><span class="icon docon docon-like"aria-hidden=true> </span> <span> Yes </span></button><button class="thumb-rating dislike has-inner-focus"aria-controls=rating-container-mobile aria-expanded=false data-bi-name=rating-no data-bi-sat=0 title=No><span class="icon docon docon-dislike"aria-hidden=true> </span> <span> No </span></button></div></div><form class="feedback-verbatim-form is-hidden"id=rating-container-mobile><div class="verbatim-textarea box position-relative box-shadow-none border has-margin-top-small has-padding-extra-small font-size-xs"><label class=visually-hidden for=rating-textarea-mobile>Any additional feedback?</label><textarea class="textarea border-none box-shadow-none has-inner-focus"placeholder="Any additional feedback?"id=rating-textarea-mobile maxlength=999 required rows=4></textarea></div><p class="font-size-xs has-line-height-reset">Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services. <a href=https://privacy.microsoft.com/en-us/privacystatement> Privacy policy. </a><div class="buttons buttons-right margin-top-xs has-margin-right-extra-small"><button class="skip-rating button button-clear button-primary button-sm"type=button>Skip</button><button class="submit-rating button button-primary button-filled button-sm"data-bi-name=rating-verbatim disabled>Submit</button></div></form></div><div class="thankyou-rating is-hidden"tabindex=-1><p>Thank you.</div></div><nav aria-label="Article Outline"data-bi-name="intopic toc"id=side-doc-outline role=navigation><h3>In this article</h3></nav></div></div></div></section><aside class="interactive-container is-visible-interactive column has-body-background-dark"id=interactive-container></aside></div></div><section class="border-top has-default-focus is-hidden-interactive has-margin-top-large"><footer class="footer-layout uhf-container has-padding"data-bi-name=footer id=footer role=contentinfo><div class="display-flex is-full-height has-padding-right-extra-large-desktop"><a class="locale-selector-link button button-clear flex-shrink-0"data-bi-name=select-locale data-mscc-ic=false href=#> <span aria-hidden=true class=icon> <span class="docon docon-world"> </span> </span> <span class=local-selector-link-text> </span> </a><div class="margin-inline-xs flex-shrink-0"><div class="dropdown has-caret-up"><button class="dropdown-trigger button button-clear button-sm has-inner-focus theme-dropdown-trigger"aria-controls=theme-menu aria-expanded=false data-bi-name=theme title=Theme><span class=icon> <span class="docon docon-sun"aria-hidden=true> </span> </span> <span> Theme </span></button><div class=dropdown-menu id=theme-menu role=menu><ul class="theme-selector has-padding-small"><li class="theme is-block"><button class="button button-clear button-sm theme-control button-block justify-content-flex-start"data-theme-to=light><span class="theme-light has-margin-right-small"> <span class="theme-selector-icon css-variable-support border is-inline-block has-body-background"aria-hidden=true> <svg viewbox="0 0 22 14"class=svg xmlns=http://www.w3.org/2000/svg><rect class=has-fill-body-background height=14 width=22></rect><rect class=has-fill-secondary height=4 width=12 x=5 y=5></rect><rect class=has-fill-secondary height=1 width=2 x=5 y=2></rect><rect class=has-fill-secondary height=1 width=2 x=8 y=2></rect><rect class=has-fill-secondary height=1 width=3 x=11 y=2></rect><rect class=has-fill-secondary height=2 width=2 x=1 y=1></rect><rect class=has-fill-primary height=2 rx=0.3 width=7 x=5 y=10></rect><rect class=has-fill-secondary height=2 rx=1 width=2 x=19 y=1></rect></svg> </span> </span> <span role=menuitem> Light </span></button><li class="theme is-block"><button class="button button-clear button-sm theme-control button-block justify-content-flex-start"data-theme-to=dark><span class="theme-dark has-margin-right-small"> <span class="border theme-selector-icon css-variable-support is-inline-block has-body-background"aria-hidden=true> <svg viewbox="0 0 22 14"class=svg xmlns=http://www.w3.org/2000/svg><rect class=has-fill-body-background height=14 width=22></rect><rect class=has-fill-secondary height=4 width=12 x=5 y=5></rect><rect class=has-fill-secondary height=1 width=2 x=5 y=2></rect><rect class=has-fill-secondary height=1 width=2 x=8 y=2></rect><rect class=has-fill-secondary height=1 width=3 x=11 y=2></rect><rect class=has-fill-secondary height=2 width=2 x=1 y=1></rect><rect class=has-fill-primary height=2 rx=0.3 width=7 x=5 y=10></rect><rect class=has-fill-secondary height=2 rx=1 width=2 x=19 y=1></rect></svg> </span> </span> <span role=menuitem> Dark </span></button><li class="theme is-block"><button class="button button-clear button-sm theme-control button-block justify-content-flex-start"data-theme-to=high-contrast><span class="theme-high-contrast has-margin-right-small"> <span class="border theme-selector-icon css-variable-support is-inline-block has-body-background"aria-hidden=true> <svg viewbox="0 0 22 14"class=svg xmlns=http://www.w3.org/2000/svg><rect class=has-fill-body-background height=14 width=22></rect><rect class=has-fill-secondary height=4 width=12 x=5 y=5></rect><rect class=has-fill-secondary height=1 width=2 x=5 y=2></rect><rect class=has-fill-secondary height=1 width=2 x=8 y=2></rect><rect class=has-fill-secondary height=1 width=3 x=11 y=2></rect><rect class=has-fill-secondary height=2 width=2 x=1 y=1></rect><rect class=has-fill-primary height=2 rx=0.3 width=7 x=5 y=10></rect><rect class=has-fill-secondary height=2 rx=1 width=2 x=19 y=1></rect></svg> </span> </span> <span role=menuitem> High contrast </span></button></ul></div></div></div></div><ul class=links data-bi-name=footerlinks><li class=manage-cookies-holder hidden><li><a data-bi-name=archivelink data-mscc-ic=false href=https://docs.microsoft.com/en-us/previous-versions/> Previous Version Docs </a><li><a data-bi-name=bloglink data-mscc-ic=false href=https://docs.microsoft.com/en-us/teamblog> Blog </a><li><a data-bi-name=contributorGuide data-mscc-ic=false href=https://docs.microsoft.com/en-us/contribute> Contribute </a><li><a data-bi-name=privacy data-mscc-ic=false href=https://go.microsoft.com/fwlink/?LinkId=521839> Privacy & Cookies </a><li><a data-bi-name=termsofuse data-mscc-ic=false href=https://docs.microsoft.com/en-us/legal/termsofuse> Terms of Use </a><li><a data-bi-name=trademarks data-mscc-ic=false href=https://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/EN-US.aspx> Trademarks </a><li>© Microsoft 2021</ul></footer></section><script crossorigin integrity=sha384-RLsAi7wiVvnmHrRjlVvUjU45C0bfsIBg6Gsxue6azjJi+lA5q5uK+XbGzO3yn5g1 src=/static/third-party/MathJax/2.7.2/MathJax.js?config=TeX-AMS_CHTML></script><div aria-label="Action Panel"class="action-panel has-default-focus"id=action-panel role=region tabindex=-1></div>