CINXE.COM

Regular expression - Wikipedia

<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Regular expression - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy", "wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"2423082d-92d4-4e1f-a072-776d58b3d375","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Regular_expression","wgTitle":"Regular expression","wgCurRevisionId":1255611009,"wgRevisionId":1255611009,"wgArticleId":25717,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Wikipedia articles needing page number citations from February 2015","CS1 Russian-language sources (ru)","Webarchive template wayback links","Articles with short description","Short description matches Wikidata","All articles with unsourced statements","Articles with unsourced statements from June 2023","Articles containing potentially dated statements from 2016","All articles containing potentially dated statements","Commons category link is on Wikidata", "Articles with example code","Regular expressions","1951 introductions","Automata (computation)","Formal languages","Pattern matching","Programming constructs"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Regular_expression","wgRelevantArticleId":25717,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgRedirectedFrom":"Regular_expressions","wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":100000,"wgInternalRedirectTargetUrl":"/wiki/Regular_expression", "wgRelatedArticlesCompat":[],"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q185612","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.pygments":"ready","ext.cite.styles":"ready","ext.math.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","jquery.tablesorter.styles":"ready","jquery.makeCollapsible.styles":"ready","ext.wikimediamessages.styles": "ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["mediawiki.action.view.redirect","ext.pygments.view","ext.cite.ux-enhancements","mediawiki.page.media","ext.scribunto.logs","site","mediawiki.page.ready","jquery.tablesorter","jquery.makeCollapsible","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.quicksurveys.init","ext.growthExperiments.SuggestedEditSession", "wikibase.sidebar.tracking"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=ext.cite.styles%7Cext.math.styles%7Cext.pygments%2CwikimediaBadges%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&amp;only=styles&amp;skin=vector-2022"> <script async="" src="/w/load.php?lang=en&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=site.styles&amp;only=styles&amp;skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.5"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/9/97/Antony08.gif"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="420"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/9/97/Antony08.gif"> <meta property="og:image:width" content="800"> <meta property="og:image:height" content="280"> <meta property="og:image:width" content="640"> <meta property="og:image:height" content="224"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Regular expression - Wikipedia"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/Regular_expression"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Regular_expression&amp;action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/Regular_expression"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&amp;feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Regular_expression rootpage-Regular_expression skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li> </ul> </div> </div> <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" > <div class="vector-menu-heading"> Contribute </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Main_Page" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page&#039;s font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_en.wikipedia.org&amp;uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&amp;returnto=Regular+expression" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&amp;returnto=Regular+expression" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_en.wikipedia.org&amp;uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&amp;returnto=Regular+expression" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&amp;returnto=Regular+expression" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">(Top)</div> </a> </li> <li id="toc-History" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#History"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>History</span> </div> </a> <ul id="toc-History-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Patterns" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Patterns"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Patterns</span> </div> </a> <ul id="toc-Patterns-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Basic_concepts" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Basic_concepts"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Basic concepts</span> </div> </a> <ul id="toc-Basic_concepts-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Formal_language_theory" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Formal_language_theory"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Formal language theory</span> </div> </a> <button aria-controls="toc-Formal_language_theory-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Formal language theory subsection</span> </button> <ul id="toc-Formal_language_theory-sublist" class="vector-toc-list"> <li id="toc-Formal_definition" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Formal_definition"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>Formal definition</span> </div> </a> <ul id="toc-Formal_definition-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Expressive_power_and_compactness" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Expressive_power_and_compactness"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>Expressive power and compactness</span> </div> </a> <ul id="toc-Expressive_power_and_compactness-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Deciding_equivalence_of_regular_expressions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Deciding_equivalence_of_regular_expressions"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3</span> <span>Deciding equivalence of regular expressions</span> </div> </a> <ul id="toc-Deciding_equivalence_of_regular_expressions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Syntax" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Syntax"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Syntax</span> </div> </a> <button aria-controls="toc-Syntax-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Syntax subsection</span> </button> <ul id="toc-Syntax-sublist" class="vector-toc-list"> <li id="toc-Delimiters" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Delimiters"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>Delimiters</span> </div> </a> <ul id="toc-Delimiters-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-IEEE_POSIX_Standard" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#IEEE_POSIX_Standard"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2</span> <span>IEEE POSIX Standard</span> </div> </a> <ul id="toc-IEEE_POSIX_Standard-sublist" class="vector-toc-list"> <li id="toc-POSIX_basic_and_extended" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#POSIX_basic_and_extended"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.1</span> <span>POSIX basic and extended</span> </div> </a> <ul id="toc-POSIX_basic_and_extended-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Metacharacters_in_POSIX_extended" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Metacharacters_in_POSIX_extended"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.2</span> <span>Metacharacters in POSIX extended</span> </div> </a> <ul id="toc-Metacharacters_in_POSIX_extended-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Character_classes" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Character_classes"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.3</span> <span>Character classes</span> </div> </a> <ul id="toc-Character_classes-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Perl_and_PCRE" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Perl_and_PCRE"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.3</span> <span>Perl and PCRE</span> </div> </a> <ul id="toc-Perl_and_PCRE-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Lazy_matching" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Lazy_matching"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.4</span> <span>Lazy matching</span> </div> </a> <ul id="toc-Lazy_matching-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Possessive_matching" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Possessive_matching"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.5</span> <span>Possessive matching</span> </div> </a> <ul id="toc-Possessive_matching-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-IETF_I-Regexp" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#IETF_I-Regexp"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.6</span> <span>IETF I-Regexp</span> </div> </a> <ul id="toc-IETF_I-Regexp-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Patterns_for_non-regular_languages" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Patterns_for_non-regular_languages"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Patterns for non-regular languages</span> </div> </a> <button aria-controls="toc-Patterns_for_non-regular_languages-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Patterns for non-regular languages subsection</span> </button> <ul id="toc-Patterns_for_non-regular_languages-sublist" class="vector-toc-list"> <li id="toc-Assertions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Assertions"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.1</span> <span>Assertions</span> </div> </a> <ul id="toc-Assertions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Implementations_and_running_times" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Implementations_and_running_times"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>Implementations and running times</span> </div> </a> <ul id="toc-Implementations_and_running_times-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Unicode" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Unicode"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>Unicode</span> </div> </a> <ul id="toc-Unicode-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Language_support" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Language_support"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>Language support</span> </div> </a> <ul id="toc-Language_support-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Uses" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Uses"> <div class="vector-toc-text"> <span class="vector-toc-numb">10</span> <span>Uses</span> </div> </a> <ul id="toc-Uses-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Examples" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Examples"> <div class="vector-toc-text"> <span class="vector-toc-numb">11</span> <span>Examples</span> </div> </a> <ul id="toc-Examples-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Induction" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Induction"> <div class="vector-toc-text"> <span class="vector-toc-numb">12</span> <span>Induction</span> </div> </a> <ul id="toc-Induction-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">13</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Notes" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Notes"> <div class="vector-toc-text"> <span class="vector-toc-numb">14</span> <span>Notes</span> </div> </a> <ul id="toc-Notes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">15</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">16</span> <span>External links</span> </div> </a> <ul id="toc-External_links-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Regular expression</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Go to an article in another language. Available in 58 languages" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-58" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">58 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-af mw-list-item"><a href="https://af.wikipedia.org/wiki/Regul%C3%AAre_uitdrukking" title="Regulêre uitdrukking – Afrikaans" lang="af" hreflang="af" data-title="Regulêre uitdrukking" data-language-autonym="Afrikaans" data-language-local-name="Afrikaans" class="interlanguage-link-target"><span>Afrikaans</span></a></li><li class="interlanguage-link interwiki-ar mw-list-item"><a href="https://ar.wikipedia.org/wiki/%D8%AA%D8%B9%D8%A8%D9%8A%D8%B1_%D9%86%D9%85%D8%B7%D9%8A" title="تعبير نمطي – Arabic" lang="ar" hreflang="ar" data-title="تعبير نمطي" data-language-autonym="العربية" data-language-local-name="Arabic" class="interlanguage-link-target"><span>العربية</span></a></li><li class="interlanguage-link interwiki-az mw-list-item"><a href="https://az.wikipedia.org/wiki/Requlyar_ifad%C9%99" title="Requlyar ifadə – Azerbaijani" lang="az" hreflang="az" data-title="Requlyar ifadə" data-language-autonym="Azərbaycanca" data-language-local-name="Azerbaijani" class="interlanguage-link-target"><span>Azərbaycanca</span></a></li><li class="interlanguage-link interwiki-bn mw-list-item"><a href="https://bn.wikipedia.org/wiki/%E0%A6%B0%E0%A7%87%E0%A6%97%E0%A7%81%E0%A6%B2%E0%A6%BE%E0%A6%B0_%E0%A6%8F%E0%A6%95%E0%A7%8D%E0%A6%B8%E0%A6%AA%E0%A7%8D%E0%A6%B0%E0%A7%87%E0%A6%B6%E0%A6%A8" title="রেগুলার এক্সপ্রেশন – Bangla" lang="bn" hreflang="bn" data-title="রেগুলার এক্সপ্রেশন" data-language-autonym="বাংলা" data-language-local-name="Bangla" class="interlanguage-link-target"><span>বাংলা</span></a></li><li class="interlanguage-link interwiki-bg mw-list-item"><a href="https://bg.wikipedia.org/wiki/%D0%A0%D0%B5%D0%B3%D1%83%D0%BB%D1%8F%D1%80%D0%B5%D0%BD_%D0%B8%D0%B7%D1%80%D0%B0%D0%B7" title="Регулярен израз – Bulgarian" lang="bg" hreflang="bg" data-title="Регулярен израз" data-language-autonym="Български" data-language-local-name="Bulgarian" class="interlanguage-link-target"><span>Български</span></a></li><li class="interlanguage-link interwiki-bar mw-list-item"><a href="https://bar.wikipedia.org/wiki/Regex" title="Regex – Bavarian" lang="bar" hreflang="bar" data-title="Regex" data-language-autonym="Boarisch" data-language-local-name="Bavarian" class="interlanguage-link-target"><span>Boarisch</span></a></li><li class="interlanguage-link interwiki-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Expressi%C3%B3_regular" title="Expressió regular – Catalan" lang="ca" hreflang="ca" data-title="Expressió regular" data-language-autonym="Català" data-language-local-name="Catalan" class="interlanguage-link-target"><span>Català</span></a></li><li class="interlanguage-link interwiki-cs mw-list-item"><a href="https://cs.wikipedia.org/wiki/Regul%C3%A1rn%C3%AD_v%C3%BDraz" title="Regulární výraz – Czech" lang="cs" hreflang="cs" data-title="Regulární výraz" data-language-autonym="Čeština" data-language-local-name="Czech" class="interlanguage-link-target"><span>Čeština</span></a></li><li class="interlanguage-link interwiki-da mw-list-item"><a href="https://da.wikipedia.org/wiki/Regul%C3%A6rt_udtryk" title="Regulært udtryk – Danish" lang="da" hreflang="da" data-title="Regulært udtryk" data-language-autonym="Dansk" data-language-local-name="Danish" class="interlanguage-link-target"><span>Dansk</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Regul%C3%A4rer_Ausdruck" title="Regulärer Ausdruck – German" lang="de" hreflang="de" data-title="Regulärer Ausdruck" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-et mw-list-item"><a href="https://et.wikipedia.org/wiki/Regulaaravaldis" title="Regulaaravaldis – Estonian" lang="et" hreflang="et" data-title="Regulaaravaldis" data-language-autonym="Eesti" data-language-local-name="Estonian" class="interlanguage-link-target"><span>Eesti</span></a></li><li class="interlanguage-link interwiki-el mw-list-item"><a href="https://el.wikipedia.org/wiki/%CE%9A%CE%B1%CE%BD%CE%BF%CE%BD%CE%B9%CE%BA%CE%AE_%CE%AD%CE%BA%CF%86%CF%81%CE%B1%CF%83%CE%B7" title="Κανονική έκφραση – Greek" lang="el" hreflang="el" data-title="Κανονική έκφραση" data-language-autonym="Ελληνικά" data-language-local-name="Greek" class="interlanguage-link-target"><span>Ελληνικά</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Expresi%C3%B3n_regular" title="Expresión regular – Spanish" lang="es" hreflang="es" data-title="Expresión regular" data-language-autonym="Español" data-language-local-name="Spanish" class="interlanguage-link-target"><span>Español</span></a></li><li class="interlanguage-link interwiki-eo mw-list-item"><a href="https://eo.wikipedia.org/wiki/Regula_esprimo" title="Regula esprimo – Esperanto" lang="eo" hreflang="eo" data-title="Regula esprimo" data-language-autonym="Esperanto" data-language-local-name="Esperanto" class="interlanguage-link-target"><span>Esperanto</span></a></li><li class="interlanguage-link interwiki-eu mw-list-item"><a href="https://eu.wikipedia.org/wiki/Adierazpen_erregular" title="Adierazpen erregular – Basque" lang="eu" hreflang="eu" data-title="Adierazpen erregular" data-language-autonym="Euskara" data-language-local-name="Basque" class="interlanguage-link-target"><span>Euskara</span></a></li><li class="interlanguage-link interwiki-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%D8%B9%D8%A8%D8%A7%D8%B1%D8%AA_%D8%A8%D8%A7%D9%82%D8%A7%D8%B9%D8%AF%D9%87" title="عبارت باقاعده – Persian" lang="fa" hreflang="fa" data-title="عبارت باقاعده" data-language-autonym="فارسی" data-language-local-name="Persian" class="interlanguage-link-target"><span>فارسی</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Expression_r%C3%A9guli%C3%A8re" title="Expression régulière – French" lang="fr" hreflang="fr" data-title="Expression régulière" data-language-autonym="Français" data-language-local-name="French" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-gl mw-list-item"><a href="https://gl.wikipedia.org/wiki/Expresi%C3%B3n_regular" title="Expresión regular – Galician" lang="gl" hreflang="gl" data-title="Expresión regular" data-language-autonym="Galego" data-language-local-name="Galician" class="interlanguage-link-target"><span>Galego</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%EC%A0%95%EA%B7%9C_%ED%91%9C%ED%98%84%EC%8B%9D" title="정규 표현식 – Korean" lang="ko" hreflang="ko" data-title="정규 표현식" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-hy mw-list-item"><a href="https://hy.wikipedia.org/wiki/%D4%BF%D5%A1%D5%B6%D5%B8%D5%B6%D5%A1%D5%BE%D5%B8%D6%80_%D5%A1%D6%80%D5%BF%D5%A1%D5%B0%D5%A1%D5%B5%D5%BF%D5%B8%D6%82%D5%A9%D5%B5%D5%B8%D6%82%D5%B6%D5%B6%D5%A5%D6%80" title="Կանոնավոր արտահայտություններ – Armenian" lang="hy" hreflang="hy" data-title="Կանոնավոր արտահայտություններ" data-language-autonym="Հայերեն" data-language-local-name="Armenian" class="interlanguage-link-target"><span>Հայերեն</span></a></li><li class="interlanguage-link interwiki-hi mw-list-item"><a href="https://hi.wikipedia.org/wiki/%E0%A4%B0%E0%A5%87%E0%A4%97%E0%A5%8D%E0%A4%AF%E0%A5%81%E0%A4%B2%E0%A4%B0_%E0%A4%8D%E0%A4%95%E0%A5%8D%E0%A4%B8%E0%A4%AA%E0%A5%8D%E0%A4%B0%E0%A5%88%E0%A4%B6%E0%A4%A8" title="रेग्युलर ऍक्सप्रैशन – Hindi" lang="hi" hreflang="hi" data-title="रेग्युलर ऍक्सप्रैशन" data-language-autonym="हिन्दी" data-language-local-name="Hindi" class="interlanguage-link-target"><span>हिन्दी</span></a></li><li class="interlanguage-link interwiki-hr mw-list-item"><a href="https://hr.wikipedia.org/wiki/Regularni_izraz" title="Regularni izraz – Croatian" lang="hr" hreflang="hr" data-title="Regularni izraz" data-language-autonym="Hrvatski" data-language-local-name="Croatian" class="interlanguage-link-target"><span>Hrvatski</span></a></li><li class="interlanguage-link interwiki-id mw-list-item"><a href="https://id.wikipedia.org/wiki/Ekspresi_reguler" title="Ekspresi reguler – Indonesian" lang="id" hreflang="id" data-title="Ekspresi reguler" data-language-autonym="Bahasa Indonesia" data-language-local-name="Indonesian" class="interlanguage-link-target"><span>Bahasa Indonesia</span></a></li><li class="interlanguage-link interwiki-is mw-list-item"><a href="https://is.wikipedia.org/wiki/Regluleg_seg%C3%B0" title="Regluleg segð – Icelandic" lang="is" hreflang="is" data-title="Regluleg segð" data-language-autonym="Íslenska" data-language-local-name="Icelandic" class="interlanguage-link-target"><span>Íslenska</span></a></li><li class="interlanguage-link interwiki-it mw-list-item"><a href="https://it.wikipedia.org/wiki/Espressione_regolare" title="Espressione regolare – Italian" lang="it" hreflang="it" data-title="Espressione regolare" data-language-autonym="Italiano" data-language-local-name="Italian" class="interlanguage-link-target"><span>Italiano</span></a></li><li class="interlanguage-link interwiki-he mw-list-item"><a href="https://he.wikipedia.org/wiki/%D7%91%D7%99%D7%98%D7%95%D7%99_%D7%A8%D7%92%D7%95%D7%9C%D7%A8%D7%99" title="ביטוי רגולרי – Hebrew" lang="he" hreflang="he" data-title="ביטוי רגולרי" data-language-autonym="עברית" data-language-local-name="Hebrew" class="interlanguage-link-target"><span>עברית</span></a></li><li class="interlanguage-link interwiki-ka mw-list-item"><a href="https://ka.wikipedia.org/wiki/%E1%83%A0%E1%83%94%E1%83%92%E1%83%A3%E1%83%9A%E1%83%90%E1%83%A0%E1%83%A3%E1%83%9A%E1%83%98_%E1%83%92%E1%83%90%E1%83%9B%E1%83%9D%E1%83%A1%E1%83%90%E1%83%AE%E1%83%A3%E1%83%9A%E1%83%94%E1%83%91%E1%83%90" title="რეგულარული გამოსახულება – Georgian" lang="ka" hreflang="ka" data-title="რეგულარული გამოსახულება" data-language-autonym="ქართული" data-language-local-name="Georgian" class="interlanguage-link-target"><span>ქართული</span></a></li><li class="interlanguage-link interwiki-ky mw-list-item"><a href="https://ky.wikipedia.org/wiki/%D0%A0%D0%B5%D0%B3%D1%83%D0%BB%D1%8F%D1%80%D0%B4%D1%8B%D0%BA_%D1%82%D1%83%D1%8E%D0%BD%D1%82%D0%BC%D0%B0" title="Регулярдык туюнтма – Kyrgyz" lang="ky" hreflang="ky" data-title="Регулярдык туюнтма" data-language-autonym="Кыргызча" data-language-local-name="Kyrgyz" class="interlanguage-link-target"><span>Кыргызча</span></a></li><li class="interlanguage-link interwiki-lv mw-list-item"><a href="https://lv.wikipedia.org/wiki/Regul%C4%81r%C4%81_izteiksme" title="Regulārā izteiksme – Latvian" lang="lv" hreflang="lv" data-title="Regulārā izteiksme" data-language-autonym="Latviešu" data-language-local-name="Latvian" class="interlanguage-link-target"><span>Latviešu</span></a></li><li class="interlanguage-link interwiki-hu mw-list-item"><a href="https://hu.wikipedia.org/wiki/Regul%C3%A1ris_kifejez%C3%A9s" title="Reguláris kifejezés – Hungarian" lang="hu" hreflang="hu" data-title="Reguláris kifejezés" data-language-autonym="Magyar" data-language-local-name="Hungarian" class="interlanguage-link-target"><span>Magyar</span></a></li><li class="interlanguage-link interwiki-mk mw-list-item"><a href="https://mk.wikipedia.org/wiki/%D0%A0%D0%B5%D0%B3%D1%83%D0%BB%D0%B0%D1%80%D0%B5%D0%BD_%D0%B8%D0%B7%D1%80%D0%B0%D0%B7" title="Регуларен израз – Macedonian" lang="mk" hreflang="mk" data-title="Регуларен израз" data-language-autonym="Македонски" data-language-local-name="Macedonian" class="interlanguage-link-target"><span>Македонски</span></a></li><li class="interlanguage-link interwiki-ml mw-list-item"><a href="https://ml.wikipedia.org/wiki/%E0%B4%B1%E0%B5%86%E0%B4%97%E0%B5%81%E0%B4%B2%E0%B5%BC_%E0%B4%8E%E0%B4%95%E0%B5%8D%E0%B4%B8%E0%B5%8D%E0%B4%AA%E0%B5%8D%E0%B4%B0%E0%B4%B7%E0%B4%A8%E0%B5%81%E0%B4%95%E0%B5%BE" title="റെഗുലർ എക്സ്പ്രഷനുകൾ – Malayalam" lang="ml" hreflang="ml" data-title="റെഗുലർ എക്സ്പ്രഷനുകൾ" data-language-autonym="മലയാളം" data-language-local-name="Malayalam" class="interlanguage-link-target"><span>മലയാളം</span></a></li><li class="interlanguage-link interwiki-mwl mw-list-item"><a href="https://mwl.wikipedia.org/wiki/Spresson_Regular" title="Spresson Regular – Mirandese" lang="mwl" hreflang="mwl" data-title="Spresson Regular" data-language-autonym="Mirandés" data-language-local-name="Mirandese" class="interlanguage-link-target"><span>Mirandés</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Reguliere_expressie" title="Reguliere expressie – Dutch" lang="nl" hreflang="nl" data-title="Reguliere expressie" data-language-autonym="Nederlands" data-language-local-name="Dutch" class="interlanguage-link-target"><span>Nederlands</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/%E6%AD%A3%E8%A6%8F%E8%A1%A8%E7%8F%BE" title="正規表現 – Japanese" lang="ja" hreflang="ja" data-title="正規表現" data-language-autonym="日本語" data-language-local-name="Japanese" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-no mw-list-item"><a href="https://no.wikipedia.org/wiki/Regul%C3%A6rt_uttrykk" title="Regulært uttrykk – Norwegian Bokmål" lang="nb" hreflang="nb" data-title="Regulært uttrykk" data-language-autonym="Norsk bokmål" data-language-local-name="Norwegian Bokmål" class="interlanguage-link-target"><span>Norsk bokmål</span></a></li><li class="interlanguage-link interwiki-pnb mw-list-item"><a href="https://pnb.wikipedia.org/wiki/%D8%B1%DB%8C%D8%AC%DB%8C%DA%A9%D8%B3" title="ریجیکس – Western Punjabi" lang="pnb" hreflang="pnb" data-title="ریجیکس" data-language-autonym="پنجابی" data-language-local-name="Western Punjabi" class="interlanguage-link-target"><span>پنجابی</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Wyra%C5%BCenie_regularne" title="Wyrażenie regularne – Polish" lang="pl" hreflang="pl" data-title="Wyrażenie regularne" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Express%C3%A3o_regular" title="Expressão regular – Portuguese" lang="pt" hreflang="pt" data-title="Expressão regular" data-language-autonym="Português" data-language-local-name="Portuguese" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ro mw-list-item"><a href="https://ro.wikipedia.org/wiki/Expresie_regulat%C4%83" title="Expresie regulată – Romanian" lang="ro" hreflang="ro" data-title="Expresie regulată" data-language-autonym="Română" data-language-local-name="Romanian" class="interlanguage-link-target"><span>Română</span></a></li><li class="interlanguage-link interwiki-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/%D0%A0%D0%B5%D0%B3%D1%83%D0%BB%D1%8F%D1%80%D0%BD%D1%8B%D0%B5_%D0%B2%D1%8B%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D1%8F" title="Регулярные выражения – Russian" lang="ru" hreflang="ru" data-title="Регулярные выражения" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-sq mw-list-item"><a href="https://sq.wikipedia.org/wiki/Shprehje_e_rregullt" title="Shprehje e rregullt – Albanian" lang="sq" hreflang="sq" data-title="Shprehje e rregullt" data-language-autonym="Shqip" data-language-local-name="Albanian" class="interlanguage-link-target"><span>Shqip</span></a></li><li class="interlanguage-link interwiki-simple mw-list-item"><a href="https://simple.wikipedia.org/wiki/Regular_expression" title="Regular expression – Simple English" lang="en-simple" hreflang="en-simple" data-title="Regular expression" data-language-autonym="Simple English" data-language-local-name="Simple English" class="interlanguage-link-target"><span>Simple English</span></a></li><li class="interlanguage-link interwiki-sk mw-list-item"><a href="https://sk.wikipedia.org/wiki/Regul%C3%A1rny_v%C3%BDraz" title="Regulárny výraz – Slovak" lang="sk" hreflang="sk" data-title="Regulárny výraz" data-language-autonym="Slovenčina" data-language-local-name="Slovak" class="interlanguage-link-target"><span>Slovenčina</span></a></li><li class="interlanguage-link interwiki-sl mw-list-item"><a href="https://sl.wikipedia.org/wiki/Regularni_izraz" title="Regularni izraz – Slovenian" lang="sl" hreflang="sl" data-title="Regularni izraz" data-language-autonym="Slovenščina" data-language-local-name="Slovenian" class="interlanguage-link-target"><span>Slovenščina</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/Regularni_izraz" title="Regularni izraz – Serbian" lang="sr" hreflang="sr" data-title="Regularni izraz" data-language-autonym="Српски / srpski" data-language-local-name="Serbian" class="interlanguage-link-target"><span>Српски / srpski</span></a></li><li class="interlanguage-link interwiki-fi mw-list-item"><a href="https://fi.wikipedia.org/wiki/S%C3%A4%C3%A4nn%C3%B6llinen_lauseke" title="Säännöllinen lauseke – Finnish" lang="fi" hreflang="fi" data-title="Säännöllinen lauseke" data-language-autonym="Suomi" data-language-local-name="Finnish" class="interlanguage-link-target"><span>Suomi</span></a></li><li class="interlanguage-link interwiki-sv mw-list-item"><a href="https://sv.wikipedia.org/wiki/Regulj%C3%A4ra_uttryck" title="Reguljära uttryck – Swedish" lang="sv" hreflang="sv" data-title="Reguljära uttryck" data-language-autonym="Svenska" data-language-local-name="Swedish" class="interlanguage-link-target"><span>Svenska</span></a></li><li class="interlanguage-link interwiki-ta mw-list-item"><a href="https://ta.wikipedia.org/wiki/%E0%AE%9A%E0%AF%81%E0%AE%B0%E0%AF%81%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AF%81%E0%AE%B1%E0%AE%BF%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AF%8A%E0%AE%9F%E0%AE%B0%E0%AF%8D" title="சுருங்குறித்தொடர் – Tamil" lang="ta" hreflang="ta" data-title="சுருங்குறித்தொடர்" data-language-autonym="தமிழ்" data-language-local-name="Tamil" class="interlanguage-link-target"><span>தமிழ்</span></a></li><li class="interlanguage-link interwiki-th mw-list-item"><a href="https://th.wikipedia.org/wiki/%E0%B8%99%E0%B8%B4%E0%B8%9E%E0%B8%88%E0%B8%99%E0%B9%8C%E0%B8%9B%E0%B8%A3%E0%B8%81%E0%B8%95%E0%B8%B4" title="นิพจน์ปรกติ – Thai" lang="th" hreflang="th" data-title="นิพจน์ปรกติ" data-language-autonym="ไทย" data-language-local-name="Thai" class="interlanguage-link-target"><span>ไทย</span></a></li><li class="interlanguage-link interwiki-tr mw-list-item"><a href="https://tr.wikipedia.org/wiki/D%C3%BCzenli_ifade" title="Düzenli ifade – Turkish" lang="tr" hreflang="tr" data-title="Düzenli ifade" data-language-autonym="Türkçe" data-language-local-name="Turkish" class="interlanguage-link-target"><span>Türkçe</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%A0%D0%B5%D0%B3%D1%83%D0%BB%D1%8F%D1%80%D0%BD%D0%B8%D0%B9_%D0%B2%D0%B8%D1%80%D0%B0%D0%B7" title="Регулярний вираз – Ukrainian" lang="uk" hreflang="uk" data-title="Регулярний вираз" data-language-autonym="Українська" data-language-local-name="Ukrainian" class="interlanguage-link-target"><span>Українська</span></a></li><li class="interlanguage-link interwiki-ur mw-list-item"><a href="https://ur.wikipedia.org/wiki/%D8%B1%DB%8C%D8%AC%DB%8C%DA%A9%D8%B3" title="ریجیکس – Urdu" lang="ur" hreflang="ur" data-title="ریجیکس" data-language-autonym="اردو" data-language-local-name="Urdu" class="interlanguage-link-target"><span>اردو</span></a></li><li class="interlanguage-link interwiki-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/Bi%E1%BB%83u_th%E1%BB%A9c_ch%C3%ADnh_quy" title="Biểu thức chính quy – Vietnamese" lang="vi" hreflang="vi" data-title="Biểu thức chính quy" data-language-autonym="Tiếng Việt" data-language-local-name="Vietnamese" class="interlanguage-link-target"><span>Tiếng Việt</span></a></li><li class="interlanguage-link interwiki-wa mw-list-item"><a href="https://wa.wikipedia.org/wiki/Er%C3%AEl%C3%AAye_ratourneure" title="Erîlêye ratourneure – Walloon" lang="wa" hreflang="wa" data-title="Erîlêye ratourneure" data-language-autonym="Walon" data-language-local-name="Walloon" class="interlanguage-link-target"><span>Walon</span></a></li><li class="interlanguage-link interwiki-wuu mw-list-item"><a href="https://wuu.wikipedia.org/wiki/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F" title="正则表达式 – Wu" lang="wuu" hreflang="wuu" data-title="正则表达式" data-language-autonym="吴语" data-language-local-name="Wu" class="interlanguage-link-target"><span>吴语</span></a></li><li class="interlanguage-link interwiki-zh-yue mw-list-item"><a href="https://zh-yue.wikipedia.org/wiki/%E6%AD%A3%E5%89%87%E8%A1%A8%E9%81%94%E5%BC%8F" title="正則表達式 – Cantonese" lang="yue" hreflang="yue" data-title="正則表達式" data-language-autonym="粵語" data-language-local-name="Cantonese" class="interlanguage-link-target"><span>粵語</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F" title="正则表达式 – Chinese" lang="zh" hreflang="zh" data-title="正则表达式" data-language-autonym="中文" data-language-local-name="Chinese" class="interlanguage-link-target"><span>中文</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q185612#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Regular_expression" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Regular_expression" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Regular_expression"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Regular_expression&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Regular_expression&amp;action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Regular_expression"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Regular_expression&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Regular_expression&amp;action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Regular_expression" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Regular_expression" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Regular_expression&amp;oldid=1255611009" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Regular_expression&amp;action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&amp;page=Regular_expression&amp;id=1255611009&amp;wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FRegular_expression"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FRegular_expression"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&amp;page=Regular_expression&amp;action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Regular_expression&amp;printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="wb-otherproject-link wb-otherproject-commons mw-list-item"><a href="https://commons.wikimedia.org/wiki/Category:Regex" hreflang="en"><span>Wikimedia Commons</span></a></li><li class="wb-otherproject-link wb-otherproject-wikibooks mw-list-item"><a href="https://en.wikibooks.org/wiki/Regular_Expressions" hreflang="en"><span>Wikibooks</span></a></li><li class="wb-otherproject-link wb-otherproject-wikiversity mw-list-item"><a href="https://en.wikiversity.org/wiki/Regular_expressions" hreflang="en"><span>Wikiversity</span></a></li><li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q185612" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"><span class="mw-redirectedfrom">(Redirected from <a href="/w/index.php?title=Regular_expressions&amp;redirect=no" class="mw-redirect" title="Regular expressions">Regular expressions</a>)</span></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">Sequence of characters that forms a search pattern</div> <style data-mw-deduplicate="TemplateStyles:r1236090951">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}</style><div role="note" class="hatnote navigation-not-searchable">"Regex" redirects here. For the comic book, see <a href="/wiki/Re:Gex" class="mw-redirect" title="Re:Gex"><i>Re:Gex</i></a>.</div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951"><div role="note" class="hatnote navigation-not-searchable">".*" redirects here. For the C++ operator, see <a href="/wiki/Pointer_(computer_science)#Pointer-to-member" class="mw-redirect" title="Pointer (computer science)">Pointer (computer science) §&#160;Pointer-to-member</a>.</div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Antony08.gif" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/9/97/Antony08.gif/330px-Antony08.gif" decoding="async" width="330" height="116" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/9/97/Antony08.gif 1.5x" data-file-width="474" data-file-height="166" /></a><figcaption><style data-mw-deduplicate="TemplateStyles:r981673959">.mw-parser-output .legend{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .legend-color{display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;text-align:center;border:1px solid black;background-color:transparent;color:black}.mw-parser-output .legend-text{}</style><div class="legend"><span class="legend-color mw-no-invert" style="border: 1px solid #b0d0f0;background-color:#b0d0f0; color:black;"><span class="legend-text" style="font-family: monospace, monospace;">Blue</span></span>&#160;highlights show the match results of the regular expression pattern: <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="sr">/r[aeiou]+/</span><span class="nv">g</span></code> (lower case <i>r</i> followed by one or more lower-case vowels).</div></figcaption></figure> <p>A <b>regular expression</b> (shortened as <b>regex</b> or <b>regexp</b>),<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> sometimes referred to as <b>rational expression</b>,<sup id="cite_ref-Mitkov2003_2-0" class="reference"><a href="#cite_note-Mitkov2003-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-Lawson2003_3-0" class="reference"><a href="#cite_note-Lawson2003-3"><span class="cite-bracket">&#91;</span>3<span class="cite-bracket">&#93;</span></a></sup> is a sequence of <a href="/wiki/Character_(computing)" title="Character (computing)">characters</a> that specifies a <a href="/wiki/Pattern_matching" title="Pattern matching">match pattern</a> in <a href="/wiki/String_(computer_science)" title="String (computer science)">text</a>. Usually such patterns are used by <a href="/wiki/String-searching_algorithm" title="String-searching algorithm">string-searching algorithms</a> for "find" or "find and replace" operations on <a href="/wiki/String_(computer_science)" title="String (computer science)">strings</a>, or for <a href="/wiki/Data_validation" title="Data validation">input validation</a>. Regular expression techniques are developed in <a href="/wiki/Theoretical_computer_science" title="Theoretical computer science">theoretical computer science</a> and <a href="/wiki/Formal_language" title="Formal language">formal language</a> theory. </p><p>The concept of regular expressions began in the 1950s, when the American mathematician <a href="/wiki/Stephen_Cole_Kleene" title="Stephen Cole Kleene">Stephen Cole Kleene</a> formalized the concept of a <a href="/wiki/Regular_language" title="Regular language">regular language</a>. They came into common use with <a href="/wiki/Unix" title="Unix">Unix</a> text-processing utilities. Different <a href="/wiki/Syntax_(programming_languages)" title="Syntax (programming languages)">syntaxes</a> for writing regular expressions have existed since the 1980s, one being the <a href="/wiki/POSIX" title="POSIX">POSIX</a> standard and another, widely used, being the <a href="/wiki/Perl" title="Perl">Perl</a> syntax. </p><p>Regular expressions are used in <a href="/wiki/Search_engine" title="Search engine">search engines</a>, in search and replace dialogs of <a href="/wiki/Word_processor" title="Word processor">word processors</a> and <a href="/wiki/Text_editor" title="Text editor">text editors</a>, in <a href="/wiki/Text_processing" title="Text processing">text processing</a> utilities such as <a href="/wiki/Sed" title="Sed">sed</a> and <a href="/wiki/AWK" title="AWK">AWK</a>, and in <a href="/wiki/Lexical_analysis" title="Lexical analysis">lexical analysis</a>. Regular expressions are supported in many programming languages. Library implementations are often called an "<a href="/wiki/Software_engine" title="Software engine">engine</a>",<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>4<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">&#91;</span>5<span class="cite-bracket">&#93;</span></a></sup> and <a href="/wiki/Comparison_of_regular_expression_engines" title="Comparison of regular expression engines">many of these</a> are available for reuse. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="History">History</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=1" title="Edit section: History"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Kleene.jpg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Kleene.jpg/170px-Kleene.jpg" decoding="async" width="170" height="242" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Kleene.jpg/255px-Kleene.jpg 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Kleene.jpg/340px-Kleene.jpg 2x" data-file-width="562" data-file-height="800" /></a><figcaption><a href="/wiki/Stephen_Cole_Kleene" title="Stephen Cole Kleene">Stephen Cole Kleene</a>, who introduced the concept</figcaption></figure> <p>Regular expressions originated in 1951, when mathematician <a href="/wiki/Stephen_Cole_Kleene" title="Stephen Cole Kleene">Stephen Cole Kleene</a> described <a href="/wiki/Regular_language" title="Regular language">regular languages</a> using his mathematical notation called <i>regular events</i>.<sup id="cite_ref-FOOTNOTEKleene1951_6-0" class="reference"><a href="#cite_note-FOOTNOTEKleene1951-6"><span class="cite-bracket">&#91;</span>6<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-Leung,_New_Mexico_State_University,_2010_7-0" class="reference"><a href="#cite_note-Leung,_New_Mexico_State_University,_2010-7"><span class="cite-bracket">&#91;</span>7<span class="cite-bracket">&#93;</span></a></sup> These arose in <a href="/wiki/Theoretical_computer_science" title="Theoretical computer science">theoretical computer science</a>, in the subfields of <a href="/wiki/Automata_theory" title="Automata theory">automata theory</a> (models of computation) and the description and classification of <a href="/wiki/Formal_language" title="Formal language">formal languages</a>, motivated by Kleene's attempt to describe early <a href="/wiki/Perceptron" title="Perceptron">artificial neural networks</a>. (Kleene introduced it as an alternative to <a href="/wiki/McCulloch-Pitts_neuron" class="mw-redirect" title="McCulloch-Pitts neuron">McCulloch &amp; Pitts's</a> "prehensible", but admitted "We would welcome any suggestions as to a more descriptive term."<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup>) Other early implementations of <a href="/wiki/Pattern_matching" title="Pattern matching">pattern matching</a> include the <a href="/wiki/SNOBOL" title="SNOBOL">SNOBOL</a> language, which did not use regular expressions, but instead its own pattern matching constructs. </p><p>Regular expressions entered popular use from 1968 in two uses: pattern matching in a text editor<sup id="cite_ref-FOOTNOTEThompson1968_9-0" class="reference"><a href="#cite_note-FOOTNOTEThompson1968-9"><span class="cite-bracket">&#91;</span>9<span class="cite-bracket">&#93;</span></a></sup> and lexical analysis in a compiler.<sup id="cite_ref-FOOTNOTEJohnsonPorterAckleyRoss1968_10-0" class="reference"><a href="#cite_note-FOOTNOTEJohnsonPorterAckleyRoss1968-10"><span class="cite-bracket">&#91;</span>10<span class="cite-bracket">&#93;</span></a></sup> Among the first appearances of regular expressions in program form was when <a href="/wiki/Ken_Thompson" title="Ken Thompson">Ken Thompson</a> built Kleene's notation into the editor <a href="/wiki/QED_(text_editor)" title="QED (text editor)">QED</a> as a means to match patterns in <a href="/wiki/Text_file" title="Text file">text files</a>.<sup id="cite_ref-FOOTNOTEThompson1968_9-1" class="reference"><a href="#cite_note-FOOTNOTEThompson1968-9"><span class="cite-bracket">&#91;</span>9<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-Beautiful_Code_Kernighan_11-0" class="reference"><a href="#cite_note-Beautiful_Code_Kernighan-11"><span class="cite-bracket">&#91;</span>11<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">&#91;</span>12<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-FOOTNOTEAhoUllman199210.11_Bibliographic_Notes_for_Chapter_10,_p._589_13-0" class="reference"><a href="#cite_note-FOOTNOTEAhoUllman199210.11_Bibliographic_Notes_for_Chapter_10,_p._589-13"><span class="cite-bracket">&#91;</span>13<span class="cite-bracket">&#93;</span></a></sup> For speed, Thompson implemented regular expression matching by <a href="/wiki/Just-in-time_compilation" title="Just-in-time compilation">just-in-time compilation</a> (JIT) to <a href="/wiki/IBM_7094" class="mw-redirect" title="IBM 7094">IBM 7094</a> code on the <a href="/wiki/Compatible_Time-Sharing_System" title="Compatible Time-Sharing System">Compatible Time-Sharing System</a>, an important early example of JIT compilation.<sup id="cite_ref-FOOTNOTEAycock200398_14-0" class="reference"><a href="#cite_note-FOOTNOTEAycock200398-14"><span class="cite-bracket">&#91;</span>14<span class="cite-bracket">&#93;</span></a></sup> He later added this capability to the Unix editor <a href="/wiki/Ed_(text_editor)" class="mw-redirect" title="Ed (text editor)">ed</a>, which eventually led to the popular search tool <a href="/wiki/Grep" title="Grep">grep</a>'s use of regular expressions ("grep" is a word derived from the command for regular expression searching in the ed editor: <code>g/<i>re</i>/p</code> meaning "Global search for Regular Expression and Print matching lines").<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">&#91;</span>15<span class="cite-bracket">&#93;</span></a></sup> Around the same time when Thompson developed QED, a group of researchers including <a href="/wiki/Douglas_T._Ross" title="Douglas T. Ross">Douglas T. Ross</a> implemented a tool based on regular expressions that is used for lexical analysis in <a href="/wiki/Compiler" title="Compiler">compiler</a> design.<sup id="cite_ref-FOOTNOTEJohnsonPorterAckleyRoss1968_10-1" class="reference"><a href="#cite_note-FOOTNOTEJohnsonPorterAckleyRoss1968-10"><span class="cite-bracket">&#91;</span>10<span class="cite-bracket">&#93;</span></a></sup> </p><p>Many variations of these original forms of regular expressions were used in <a href="/wiki/Unix" title="Unix">Unix</a><sup id="cite_ref-FOOTNOTEAhoUllman199210.11_Bibliographic_Notes_for_Chapter_10,_p._589_13-1" class="reference"><a href="#cite_note-FOOTNOTEAhoUllman199210.11_Bibliographic_Notes_for_Chapter_10,_p._589-13"><span class="cite-bracket">&#91;</span>13<span class="cite-bracket">&#93;</span></a></sup> programs at <a href="/wiki/Bell_Labs" title="Bell Labs">Bell Labs</a> in the 1970s, including <a href="/wiki/Lex_programming_tool" class="mw-redirect" title="Lex programming tool">lex</a>, <a href="/wiki/Sed" title="Sed">sed</a>, <a href="/wiki/AWK" title="AWK">AWK</a>, and <a href="/wiki/Expr" title="Expr">expr</a>, and in other programs such as <a href="/wiki/Vi_(text_editor)" title="Vi (text editor)">vi</a>, and <a href="/wiki/Emacs" title="Emacs">Emacs</a> (which has its own, incompatible syntax and behavior). Regexes were subsequently adopted by a wide range of programs, with these early forms standardized in the <a href="/wiki/POSIX.2" class="mw-redirect" title="POSIX.2">POSIX.2</a> standard in 1992. </p><p>In the 1980s, the more complicated regexes arose in <a href="/wiki/Perl" title="Perl">Perl</a>, which originally derived from a regex library written by <a href="/wiki/Henry_Spencer" title="Henry Spencer">Henry Spencer</a> (1986), who later wrote an implementation for <a href="/wiki/Tcl" title="Tcl">Tcl</a> called <i>Advanced Regular Expressions</i>.<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">&#91;</span>16<span class="cite-bracket">&#93;</span></a></sup> The Tcl library is a hybrid <a href="/wiki/Nondeterministic_finite_automaton" title="Nondeterministic finite automaton">NFA</a>/<a href="/wiki/Deterministic_finite_automaton" title="Deterministic finite automaton">DFA</a> implementation with improved performance characteristics. Software projects that have adopted Spencer's Tcl regular expression implementation include <a href="/wiki/PostgreSQL" title="PostgreSQL">PostgreSQL</a>.<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">&#91;</span>17<span class="cite-bracket">&#93;</span></a></sup> Perl later expanded on Spencer's original library to add many new features.<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">&#91;</span>18<span class="cite-bracket">&#93;</span></a></sup> Part of the effort in the design of <a href="/wiki/Raku_(programming_language)" title="Raku (programming language)">Raku</a> (formerly named Perl 6) is to improve Perl's regex integration, and to increase their scope and capabilities to allow the definition of <a href="/wiki/Parsing_expression_grammar" title="Parsing expression grammar">parsing expression grammars</a>.<sup id="cite_ref-Apocalypse5_19-0" class="reference"><a href="#cite_note-Apocalypse5-19"><span class="cite-bracket">&#91;</span>19<span class="cite-bracket">&#93;</span></a></sup> The result is a <a href="/wiki/Mini-language" class="mw-redirect" title="Mini-language">mini-language</a> called <a href="/wiki/Raku_rules" title="Raku rules">Raku rules</a>, which are used to define Raku grammar as well as provide a tool to programmers in the language. These rules maintain existing features of Perl 5.x regexes, but also allow <a href="/wiki/Backus%E2%80%93Naur_form" title="Backus–Naur form">BNF</a>-style definition of a <a href="/wiki/Recursive_descent_parser" title="Recursive descent parser">recursive descent parser</a> via sub-rules. </p><p>The use of regexes in structured information standards for document and database modeling started in the 1960s and expanded in the 1980s when industry standards like <a href="/wiki/Standard_Generalized_Markup_Language" title="Standard Generalized Markup Language">ISO SGML</a> (precursored by ANSI "GCA 101-1983") consolidated. The kernel of the <a href="/wiki/XML_schema#Validation" title="XML schema">structure specification language</a> standards consists of regexes. Its use is evident in the <a href="/wiki/Document_Type_Definition" class="mw-redirect" title="Document Type Definition">DTD</a> element group syntax. Prior to the use of regular expressions, many search languages allowed simple wildcards, for example "*" to match any sequence of characters, and "?" to match a single character. Relics of this can be found today in the <a href="/wiki/Glob_(programming)" title="Glob (programming)">glob</a> syntax for filenames, and in the <a href="/wiki/SQL" title="SQL">SQL</a> <code>LIKE</code> operator. </p><p>Starting in 1997, <a href="/wiki/Philip_Hazel" title="Philip Hazel">Philip Hazel</a> developed <a href="/wiki/Perl_Compatible_Regular_Expressions" title="Perl Compatible Regular Expressions">PCRE</a> (Perl Compatible Regular Expressions), which attempts to closely mimic Perl's regex functionality and is used by many modern tools including <a href="/wiki/PHP" title="PHP">PHP</a> and <a href="/wiki/Apache_HTTP_Server" title="Apache HTTP Server">Apache HTTP Server</a>.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">&#91;</span>20<span class="cite-bracket">&#93;</span></a></sup> </p><p>Today, regexes are widely supported in programming languages, text processing programs (particularly <a href="/wiki/Lexer" class="mw-redirect" title="Lexer">lexers</a>), advanced text editors, and some other programs. Regex support is part of the <a href="/wiki/Standard_library" title="Standard library">standard library</a> of many programming languages, including <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> and <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, and is built into the syntax of others, including Perl and <a href="/wiki/ECMAScript" title="ECMAScript">ECMAScript</a>. In the late 2010s, several companies started to offer hardware, <a href="/wiki/FPGA" class="mw-redirect" title="FPGA">FPGA</a>,<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">&#91;</span>21<span class="cite-bracket">&#93;</span></a></sup> <a href="/wiki/GPU" class="mw-redirect" title="GPU">GPU</a><sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">&#91;</span>22<span class="cite-bracket">&#93;</span></a></sup> implementations of <a href="/wiki/PCRE" class="mw-redirect" title="PCRE">PCRE</a> compatible regex engines that are faster compared to <a href="/wiki/Central_processing_unit" title="Central processing unit">CPU</a> implementations<b>.</b> </p> <div class="mw-heading mw-heading2"><h2 id="Patterns">Patterns</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=2" title="Edit section: Patterns"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The phrase <i>regular expressions</i>, or <i>regexes</i>, is often used to mean the specific, standard textual syntax for representing patterns for matching text, as distinct from the mathematical notation described below. Each character in a regular expression (that is, each character in the string describing its pattern) is either a <a href="/wiki/Metacharacter" title="Metacharacter">metacharacter</a>, having a special meaning, or a regular character that has a literal meaning. For example, in the regex <code>b.</code>, 'b' is a literal character that matches just 'b', while '.' is a metacharacter that matches every character except a newline. Therefore, this regex matches, for example, 'b%', or 'bx', or 'b5'. Together, metacharacters and literal characters can be used to identify text of a given pattern or process a number of instances of it. Pattern matches may vary from a precise equality to a very general similarity, as controlled by the metacharacters. For example, <code>.</code> is a very general pattern, <code>[a-z]</code> (match all lower case letters from 'a' to 'z') is less general and <code>b</code> is a precise pattern (matches just 'b'). The metacharacter syntax is designed specifically to represent prescribed targets in a concise and flexible way to direct the automation of text processing of a variety of input data, in a form easy to type using a standard <a href="/wiki/ASCII" title="ASCII">ASCII</a> <a href="/wiki/Computer_keyboard" title="Computer keyboard">keyboard</a>. </p><p>A very simple case of a regular expression in this syntax is to locate a word spelled two different ways in a <a href="/wiki/Text_editor" title="Text editor">text editor</a>, the regular expression <code>seriali[sz]e</code> matches both "serialise" and "serialize". <a href="/wiki/Wildcard_character" title="Wildcard character">Wildcard characters</a> also achieve this, but are more limited in what they can pattern, as they have fewer metacharacters and a simple language-base. </p><p>The usual context of wildcard characters is in <a href="/wiki/Glob_(programming)" title="Glob (programming)">globbing</a> similar names in a list of files, whereas regexes are usually employed in applications that pattern-match text strings in general. For example, the regex <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="o">^</span><span class="s">[ \t]</span><span class="o">+|</span><span class="s">[ \t]</span><span class="o">+$</span></code> matches excess whitespace at the beginning or end of a line. An advanced regular expression that matches any numeral is <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[+-]</span><span class="o">?(</span><span class="err">\</span><span class="nv">d</span><span class="o">+(</span><span class="err">\</span><span class="o">.</span><span class="err">\</span><span class="nv">d</span><span class="o">*)?|</span><span class="err">\</span><span class="o">.</span><span class="err">\</span><span class="nv">d</span><span class="o">+)(</span><span class="s">[eE][+-]</span><span class="o">?</span><span class="err">\</span><span class="nv">d</span><span class="o">+)?</span></code>. </p> <figure class="mw-default-size mw-halign-right" typeof="mw:File/Thumb"><a href="/wiki/File:Thompson-kleene-star.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/8/8e/Thompson-kleene-star.svg/220px-Thompson-kleene-star.svg.png" decoding="async" width="220" height="110" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/8/8e/Thompson-kleene-star.svg/330px-Thompson-kleene-star.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/8/8e/Thompson-kleene-star.svg/440px-Thompson-kleene-star.svg.png 2x" data-file-width="503" data-file-height="251" /></a><figcaption><a href="/wiki/Thompson%27s_construction_algorithm" class="mw-redirect" title="Thompson&#39;s construction algorithm">Translating</a> the <a href="/wiki/Kleene_star" title="Kleene star">Kleene star</a><br />(<i>s</i>* means "zero or more of <i>s</i>")</figcaption></figure> <p>A <b>regex processor</b> translates a regular expression in the above syntax into an internal representation that can be executed and matched against a <a href="/wiki/String_(computing)" class="mw-redirect" title="String (computing)">string</a> representing the text being searched in. One possible approach is the <a href="/wiki/Thompson%27s_construction_algorithm" class="mw-redirect" title="Thompson&#39;s construction algorithm">Thompson's construction algorithm</a> to construct a <a href="/wiki/Nondeterministic_finite_automaton" title="Nondeterministic finite automaton">nondeterministic finite automaton</a> (NFA), which is then <a href="/wiki/Powerset_construction" title="Powerset construction">made deterministic</a> and the resulting <a href="/wiki/Deterministic_finite_automaton" title="Deterministic finite automaton">deterministic finite automaton</a> (DFA) is run on the target text string to recognize substrings that match the regular expression. The picture shows the NFA scheme <code><i>N</i>(<i>s</i>*)</code> obtained from the regular expression <code><i>s</i>*</code>, where <i>s</i> denotes a simpler regular expression in turn, which has already been <a href="/wiki/Recursion_(computer_science)" title="Recursion (computer science)">recursively</a> translated to the NFA <i>N</i>(<i>s</i>). </p> <div class="mw-heading mw-heading2"><h2 id="Basic_concepts">Basic concepts</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=3" title="Edit section: Basic concepts"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A regular expression, often called a <i>pattern</i>, specifies a <a href="/wiki/Set_(computer_science)" class="mw-redirect" title="Set (computer science)">set</a> of strings required for a particular purpose. A simple way to specify a finite set of strings is to list its <a href="/wiki/Data_element" title="Data element">elements</a> or members. However, there are often more concise ways: for example, the set containing the three strings "Handel", "Händel", and "Haendel" can be specified by the pattern <code>H(ä|ae?)ndel</code>; we say that this pattern <i>matches</i> each of the three strings. However, there can be many ways to write a regular expression for the same set of strings: for example, <code>(Hän|Han|Haen)del</code> also specifies the same set of three strings in this example. </p><p>Most formalisms provide the following operations to construct regular expressions. </p> <dl><dt>Boolean "or"</dt> <dd></dd> <dd>A <a href="/wiki/Vertical_bar" title="Vertical bar">vertical bar</a> separates alternatives. For example, <code class="mw-highlight mw-highlight-lang-perl mw-content-ltr" style="" dir="ltr"><span class="n">gray</span><span class="o">|</span><span class="n">grey</span></code> can match "gray" or "grey".</dd> <dt>Grouping</dt> <dd><a href="/wiki/Parentheses" class="mw-redirect" title="Parentheses">Parentheses</a> are used to define the scope and precedence of the <a href="/wiki/Operator_(programming)" class="mw-redirect" title="Operator (programming)">operators</a> (among other uses). For example, <code>gray|grey</code> and <code class="mw-highlight mw-highlight-lang-perl mw-content-ltr" style="" dir="ltr"><span class="n">gr</span><span class="p">(</span><span class="n">a</span><span class="o">|</span><span class="n">e</span><span class="p">)</span><span class="n">y</span></code> are equivalent patterns which both describe the set of "gray" or "grey".</dd> <dt>Quantification</dt> <dd>A <a href="/wiki/Quantifier_(linguistics)" class="mw-redirect" title="Quantifier (linguistics)">quantifier</a> after an element (such as a <a href="/wiki/Lexical_analysis#Token" title="Lexical analysis">token</a>, character, or group) specifies how many times the preceding element is allowed to repeat. The most common quantifiers are the <a href="/wiki/Question_mark" title="Question mark">question mark</a> <code>?</code>, the <a href="/wiki/Asterisk" title="Asterisk">asterisk</a> <code>*</code> (derived from the <a href="/wiki/Kleene_star" title="Kleene star">Kleene star</a>), and the <a href="/wiki/Plus_sign" class="mw-redirect" title="Plus sign">plus sign</a> <code>+</code> (<a href="/wiki/Kleene_plus" class="mw-redirect" title="Kleene plus">Kleene plus</a>).</dd></dl> <dl><dd><table> <tbody><tr> <td style="width:15px; vertical-align:top;"><code><b>?</b></code> </td> <td>The question mark indicates <i>zero or one</i> occurrences of the preceding element. For example, <code>colou?r</code> matches both "color" and "colour". </td></tr> <tr> <td style="vertical-align:top;"><code><b>*</b></code> </td> <td>The asterisk indicates <i>zero or more</i> occurrences of the preceding element. For example, <code>ab*c</code> matches "ac", "abc", "abbc", "abbbc", and so on. </td></tr> <tr> <td style="vertical-align:top;"><code><b>+</b></code> </td> <td>The plus sign indicates <i>one or more</i> occurrences of the preceding element. For example, <code>ab+c</code> matches "abc", "abbc", "abbbc", and so on, but not "ac". </td></tr> <tr> <td><code><b>{n}</b></code><sup id="cite_ref-grep_23-0" class="reference"><a href="#cite_note-grep-23"><span class="cite-bracket">&#91;</span>23<span class="cite-bracket">&#93;</span></a></sup> </td> <td>The preceding item is matched exactly <i>n</i> times. </td></tr> <tr> <td><code><b>{min,}</b></code><sup id="cite_ref-grep_23-1" class="reference"><a href="#cite_note-grep-23"><span class="cite-bracket">&#91;</span>23<span class="cite-bracket">&#93;</span></a></sup> </td> <td>The preceding item is matched <i>min</i> or more times. </td></tr> <tr> <td><code><b>{,max}</b></code><sup id="cite_ref-grep_23-2" class="reference"><a href="#cite_note-grep-23"><span class="cite-bracket">&#91;</span>23<span class="cite-bracket">&#93;</span></a></sup> </td> <td>The preceding item is matched up to <i>max</i> times. </td></tr> <tr> <td><code><b>{min,max}</b></code><sup id="cite_ref-grep_23-3" class="reference"><a href="#cite_note-grep-23"><span class="cite-bracket">&#91;</span>23<span class="cite-bracket">&#93;</span></a></sup> </td> <td>The preceding item is matched at least <i>min</i> times, but not more than <i>max</i> times. </td></tr></tbody></table></dd></dl> <dl><dt>Wildcard</dt> <dd></dd> <dd>The wildcard <code><b>.</b></code> matches any character. For example, <dl><dd><code>a.b</code> matches any string that contains an "a", and then any character and then "b".</dd> <dd><code>a.*b</code> matches any string that contains an "a", and then the character "b" at some later point.</dd></dl></dd></dl> <p>These constructions can be combined to form arbitrarily complex expressions, much like one can construct arithmetical expressions from numbers and the operations +, −, ×, and ÷. </p><p>The precise <a href="/wiki/Syntax" title="Syntax">syntax</a> for regular expressions varies among tools and with context; more detail is given in <a href="#Syntax">§&#160;Syntax</a>. </p> <div class="mw-heading mw-heading2"><h2 id="Formal_language_theory">Formal language theory</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=4" title="Edit section: Formal language theory"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Regular expressions describe <a href="/wiki/Regular_language" title="Regular language">regular languages</a> in <a href="/wiki/Formal_language" title="Formal language">formal language theory</a>. They have the same expressive power as <a href="/wiki/Regular_grammar" title="Regular grammar">regular grammars</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Formal_definition">Formal definition</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=5" title="Edit section: Formal definition"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Regular expressions consist of constants, which denote sets of strings, and operator symbols, which denote operations over these sets. The following definition is standard, and found as such in most textbooks on formal language theory.<sup id="cite_ref-HopcroftMotwaniUllman01_24-0" class="reference"><a href="#cite_note-HopcroftMotwaniUllman01-24"><span class="cite-bracket">&#91;</span>24<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">&#91;</span>25<span class="cite-bracket">&#93;</span></a></sup> Given a finite <a href="/wiki/Alphabet_(computer_science)" class="mw-redirect" title="Alphabet (computer science)">alphabet</a> Σ, the following constants are defined as regular expressions: </p> <ul><li>(<i>empty set</i>) ∅ denoting the set ∅.</li> <li>(<i><a href="/wiki/Empty_string" title="Empty string">empty string</a></i>) ε denoting the set containing only the "empty" string, which has no characters at all.</li> <li>(<i><a href="/wiki/String_literal" title="String literal">literal character</a></i>) <code>a</code> in Σ denoting the set containing only the character <i>a</i>.</li></ul> <p>Given regular expressions R and S, the following operations over them are defined to produce regular expressions: </p> <ul><li>(<i><a href="/wiki/Concatenation" title="Concatenation">concatenation</a></i>) <code>(RS)</code> denotes the set of strings that can be obtained by concatenating a string accepted by R and a string accepted by S (in that order). For example, let R denote {"ab", "c"} and S denote {"d", "ef"}. Then, <code>(RS)</code> denotes {"abd", "abef", "cd", "cef"}.</li> <li>(<i><a href="/wiki/Alternation_(formal_language_theory)" title="Alternation (formal language theory)">alternation</a></i>) <code>(R|S)</code> denotes the <a href="/wiki/Set_union" class="mw-redirect" title="Set union">set union</a> of sets described by R and S. For example, if R describes {"ab", "c"} and S describes {"ab", "d", "ef"}, expression <code>(R|S)</code> describes {"ab", "c", "d", "ef"}.</li> <li>(<i><a href="/wiki/Kleene_star" title="Kleene star">Kleene star</a></i>) <code>(R*)</code> denotes the smallest <a href="/wiki/Subset" title="Subset">superset</a> of the set described by <i>R</i> that contains ε and is <a href="/wiki/Closure_(mathematics)" title="Closure (mathematics)">closed</a> under string concatenation. This is the set of all strings that can be made by concatenating any finite number (including zero) of strings from the set described by R. For example, if R denotes {"0", "1"}, <code>(R*)</code> denotes the set of all finite <a href="/wiki/Binary_string" class="mw-redirect" title="Binary string">binary strings</a> (including the empty string). If R denotes {"ab", "c"}, <code>(R*)</code> denotes {ε, "ab", "c", "abab", "abc", "cab", "cc", "ababab", "abcab", ...}.</li></ul> <p>To avoid parentheses, it is assumed that the Kleene star has the highest priority followed by concatenation, then alternation. If there is no ambiguity, then parentheses may be omitted. For example, <code>(ab)c</code> can be written as <code>abc</code>, and <code>a|(b(c*))</code> can be written as <code>a|bc*</code>. Many textbooks use the symbols ∪, +, or ∨ for alternation instead of the vertical bar. </p><p><b>Examples:</b> </p> <ul><li><code>a|b*</code> denotes {ε, "a", "b", "bb", "bbb", ...}</li> <li><code>(a|b)*</code> denotes the set of all strings with no symbols other than "a" and "b", including the empty string: {ε, "a", "b", "aa", "ab", "ba", "bb", "aaa", ...}</li> <li><code>ab*(c|ε)</code> denotes the set of strings starting with "a", then zero or more "b"s and finally optionally a "c": {"a", "ac", "ab", "abc", "abb", "abbc", ...}</li> <li><code>(0|(1(01*0)*1))*</code> denotes the set of binary numbers that are multiples of 3: { ε, "0", "00", "11", "000", "011", "110", "0000", "0011", "0110", "1001", "1100", "1111", "00000", ...}</li></ul> <div class="mw-heading mw-heading3"><h3 id="Expressive_power_and_compactness">Expressive power and compactness</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=6" title="Edit section: Expressive power and compactness"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The formal definition of regular expressions is minimal on purpose, and avoids defining <code>?</code> and <code>+</code>—these can be expressed as follows: <code>a+</code>=<code>aa*</code>, and <code>a?</code>=<code>(a|ε)</code>. Sometimes the <a href="/wiki/Set_complement" class="mw-redirect" title="Set complement">complement</a> operator is added, to give a <i>generalized regular expression</i>; here <i>R<sup>c</sup></i> matches all strings over Σ* that do not match <i>R</i>. In principle, the complement operator is redundant, because it does not grant any more expressive power. However, it can make a regular expression much more concise—eliminating a single complement operator can cause a <a href="/wiki/Double_exponential_function" title="Double exponential function">double exponential</a> blow-up of its length.<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">&#91;</span>26<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">&#91;</span>27<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">&#91;</span>28<span class="cite-bracket">&#93;</span></a></sup> </p><p>Regular expressions in this sense can express the regular languages, exactly the class of languages accepted by <a href="/wiki/Deterministic_finite_automata" class="mw-redirect" title="Deterministic finite automata">deterministic finite automata</a>. There is, however, a significant difference in compactness. Some classes of regular languages can only be described by deterministic finite automata whose size grows <a href="/wiki/Exponential_growth" title="Exponential growth">exponentially</a> in the size of the shortest equivalent regular expressions. The standard example here is the languages <i>L<sub>k</sub></i> consisting of all strings over the alphabet {<i>a</i>,<i>b</i>} whose <i>k</i>th-from-last letter equals&#160;<i>a</i>. On the one hand, a regular expression describing <i>L</i><sub>4</sub> is given by <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (a\mid b)^{*}a(a\mid b)(a\mid b)(a\mid b)}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <mo>&#x2217;<!-- ∗ --></mo> </mrow> </msup> <mi>a</mi> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <mo stretchy="false">)</mo> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <mo stretchy="false">)</mo> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (a\mid b)^{*}a(a\mid b)(a\mid b)(a\mid b)}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1008564d723e96029948e028d352418db302b3e6" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:26.179ex; height:2.843ex;" alt="{\displaystyle (a\mid b)^{*}a(a\mid b)(a\mid b)(a\mid b)}"></span>. </p><p>Generalizing this pattern to <i>L<sub>k</sub></i> gives the expression: </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (a\mid b)^{*}a\underbrace {(a\mid b)(a\mid b)\cdots (a\mid b)} _{k-1{\text{ times}}}.\,}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <mo>&#x2217;<!-- ∗ --></mo> </mrow> </msup> <mi>a</mi> <munder> <mrow class="MJX-TeXAtom-OP MJX-fixedlimits"> <munder> <mrow> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <mo stretchy="false">)</mo> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <mo stretchy="false">)</mo> <mo>&#x22EF;<!-- ⋯ --></mo> <mo stretchy="false">(</mo> <mi>a</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>b</mi> <mo stretchy="false">)</mo> </mrow> <mo>&#x23DF;<!-- ⏟ --></mo> </munder> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>k</mi> <mo>&#x2212;<!-- − --></mo> <mn>1</mn> <mrow class="MJX-TeXAtom-ORD"> <mtext>&#xA0;times</mtext> </mrow> </mrow> </munder> <mo>.</mo> <mspace width="thinmathspace" /> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (a\mid b)^{*}a\underbrace {(a\mid b)(a\mid b)\cdots (a\mid b)} _{k-1{\text{ times}}}.\,}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/b0a5c464c7bcab0126735dec95018eb14d25541f" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -4.505ex; width:30.711ex; height:6.509ex;" alt="{\displaystyle (a\mid b)^{*}a\underbrace {(a\mid b)(a\mid b)\cdots (a\mid b)} _{k-1{\text{ times}}}.\,}"></span></dd></dl> <p>On the other hand, it is known that every deterministic finite automaton accepting the language <i>L<sub>k</sub></i> must have at least 2<sup><i>k</i></sup> states. Luckily, there is a simple mapping from regular expressions to the more general <a href="/wiki/Nondeterministic_finite_automata" class="mw-redirect" title="Nondeterministic finite automata">nondeterministic finite automata</a> (NFAs) that does not lead to such a blowup in size; for this reason NFAs are often used as alternative representations of regular languages. NFAs are a simple variation of the type-3 <a href="/wiki/Formal_grammar" title="Formal grammar">grammars</a> of the <a href="/wiki/Chomsky_hierarchy" title="Chomsky hierarchy">Chomsky hierarchy</a>.<sup id="cite_ref-HopcroftMotwaniUllman01_24-1" class="reference"><a href="#cite_note-HopcroftMotwaniUllman01-24"><span class="cite-bracket">&#91;</span>24<span class="cite-bracket">&#93;</span></a></sup> </p><p>In the opposite direction, there are many languages easily described by a DFA that are not easily described by a regular expression. For instance, determining the validity of a given <a href="/wiki/ISBN" title="ISBN">ISBN</a> requires computing the modulus of the integer base 11, and can be easily implemented with an 11-state DFA. However, converting it to a regular expression results in a 2,14 megabytes file .<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">&#91;</span>29<span class="cite-bracket">&#93;</span></a></sup> </p><p>Given a regular expression, <a href="/wiki/Thompson%27s_construction_algorithm" class="mw-redirect" title="Thompson&#39;s construction algorithm">Thompson's construction algorithm</a> computes an equivalent nondeterministic finite automaton. A conversion in the opposite direction is achieved by <a href="/wiki/Kleene%27s_algorithm" title="Kleene&#39;s algorithm">Kleene's algorithm</a>. </p><p>Finally, many real-world "regular expression" engines implement features that cannot be described by the regular expressions in the sense of formal language theory; rather, they implement <i>regexes</i>. See <a href="#Patterns_for_non-regular_languages">below</a> for more on this. </p> <div class="mw-heading mw-heading3"><h3 id="Deciding_equivalence_of_regular_expressions">Deciding equivalence of regular expressions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=7" title="Edit section: Deciding equivalence of regular expressions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>As seen in many of the examples above, there is more than one way to construct a regular expression to achieve the same results. </p><p>It is possible to write an <a href="/wiki/Algorithm" title="Algorithm">algorithm</a> that, for two given regular expressions, decides whether the described languages are equal; the algorithm reduces each expression to a <a href="/wiki/Minimal_deterministic_finite_state_machine" class="mw-redirect" title="Minimal deterministic finite state machine">minimal deterministic finite state machine</a>, and determines whether they are <a href="/wiki/Isomorphism" title="Isomorphism">isomorphic</a> (equivalent). </p><p>Algebraic laws for regular expressions can be obtained using a method by Gischer which is best explained along an example: In order to check whether (<i>X</i>+<i>Y</i>)<sup>*</sup> and (<i>X</i><sup>*</sup> <i>Y</i><sup>*</sup>)<sup>*</sup> denote the same regular language, for all regular expressions <i>X</i>, <i>Y</i>, it is necessary and sufficient to check whether the particular regular expressions (<i>a</i>+<i>b</i>)<sup>*</sup> and (<i>a</i><sup>*</sup> <i>b</i><sup>*</sup>)<sup>*</sup> denote the same language over the alphabet Σ={<i>a</i>,<i>b</i>}. More generally, an equation <i>E</i>=<i>F</i> between regular-expression terms with variables holds if, and only if, its instantiation with different variables replaced by different symbol constants holds.<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">&#91;</span>30<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-31" class="reference"><a href="#cite_note-31"><span class="cite-bracket">&#91;</span>31<span class="cite-bracket">&#93;</span></a></sup> </p><p>Every regular expression can be written solely in terms of the <a href="/wiki/Kleene_star" title="Kleene star">Kleene star</a> and <a href="/wiki/Union_(set_theory)" title="Union (set theory)">set unions</a> over finite words. This is a surprisingly difficult problem. As simple as the regular expressions are, there is no method to systematically rewrite them to some normal form. The lack of axiom in the past led to the <a href="/wiki/Star_height_problem" title="Star height problem">star height problem</a>. In 1991, <a href="/wiki/Dexter_Kozen" title="Dexter Kozen">Dexter Kozen</a> axiomatized regular expressions as a <a href="/wiki/Kleene_algebra#History" title="Kleene algebra">Kleene algebra</a>, using equational and <a href="/wiki/Horn_clause" title="Horn clause">Horn clause</a> axioms.<sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">&#91;</span>32<span class="cite-bracket">&#93;</span></a></sup> Already in 1964, Redko had proved that no finite set of purely equational axioms can characterize the algebra of regular languages.<sup id="cite_ref-33" class="reference"><a href="#cite_note-33"><span class="cite-bracket">&#91;</span>33<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Syntax">Syntax</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=8" title="Edit section: Syntax"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A regex <i>pattern</i> matches a target <i>string</i>. The pattern is composed of a sequence of <i>atoms</i>. An atom is a single point within the regex pattern which it tries to match to the target string. The simplest atom is a literal, but grouping parts of the pattern to match an atom will require using <code>(&#160;)</code> as metacharacters. Metacharacters help form: <i>atoms</i>; <i>quantifiers</i> telling how many atoms (and whether it is a <a href="#Lazy_matching"><i>greedy</i> quantifier</a> or not); a logical OR character, which offers a set of alternatives, and a logical NOT character, which negates an atom's existence; and backreferences to refer to previous atoms of a completing pattern of atoms. A match is made, not when all the atoms of the string are matched, but rather when all the pattern atoms in the regex have matched. The idea is to make a small pattern of characters stand for a large number of possible strings, rather than compiling a large list of all the literal possibilities. </p><p>Depending on the regex processor there are about fourteen metacharacters, characters that may or may not have their <a href="/wiki/Literal_(computer_programming)" title="Literal (computer programming)">literal</a> character meaning, depending on context, or whether they are "escaped", i.e. preceded by an <a href="/wiki/Escape_sequence" title="Escape sequence">escape sequence</a>, in this case, the backslash <code>\</code>. Modern and POSIX extended regexes use metacharacters more often than their literal meaning, so to avoid "backslash-osis" or <a href="/wiki/Leaning_toothpick_syndrome" title="Leaning toothpick syndrome">leaning toothpick syndrome</a>, they have a metacharacter escape to a literal mode; starting out, however, they instead have the four bracketing metacharacters <code>(&#160;)</code> and <code>{&#160;}</code> be primarily literal, and "escape" this usual meaning to become metacharacters. Common standards implement both. The usual metacharacters are <code> {}[]()^$.|*+?</code> and <code>\</code>. The usual characters that become metacharacters when escaped are <code>dswDSW</code> and <code>N</code>. </p> <div class="mw-heading mw-heading3"><h3 id="Delimiters">Delimiters</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=9" title="Edit section: Delimiters"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>When entering a regex in a programming language, they may be represented as a usual string literal, hence usually quoted; this is common in C, Java, and Python for instance, where the regex <code>re</code> is entered as <code>"re"</code>. However, they are often written with slashes as <a href="/wiki/Delimiter" title="Delimiter">delimiters</a>, as in <code>/re/</code> for the regex <code>re</code>. This originates in <a href="/wiki/Ed_(text_editor)" class="mw-redirect" title="Ed (text editor)">ed</a>, where <code>/</code> is the editor command for searching, and an expression <code>/re/</code> can be used to specify a range of lines (matching the pattern), which can be combined with other commands on either side, most famously <code>g/re/p</code> as in <a href="/wiki/Grep" title="Grep">grep</a> ("global regex print"), which is included in most <a href="/wiki/Unix" title="Unix">Unix</a>-based operating systems, such as <a href="/wiki/Linux" title="Linux">Linux</a> distributions. A similar convention is used in <a href="/wiki/Sed" title="Sed">sed</a>, where search and replace is given by <code>s/re/replacement/</code> and patterns can be joined with a comma to specify a range of lines as in <code>/re1/,/re2/</code>. This notation is particularly well known due to its use in <a href="/wiki/Perl" title="Perl">Perl</a>, where it forms part of the syntax distinct from normal string literals. In some cases, such as sed and Perl, alternative delimiters can be used to avoid collision with contents, and to avoid having to escape occurrences of the delimiter character in the contents. For example, in sed the command <code>s,/,X,</code> will replace a <code>/</code> with an <code>X</code>, using commas as delimiters. </p> <div class="mw-heading mw-heading3"><h3 id="IEEE_POSIX_Standard">IEEE POSIX Standard <span class="anchor" id="POSIX"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=10" title="Edit section: IEEE POSIX Standard"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The <a href="/wiki/Institute_of_Electrical_and_Electronics_Engineers" title="Institute of Electrical and Electronics Engineers">IEEE</a> <a href="/wiki/POSIX" title="POSIX">POSIX</a> standard has three sets of compliance: <b>BRE</b> (Basic Regular Expressions),<sup id="cite_ref-34" class="reference"><a href="#cite_note-34"><span class="cite-bracket">&#91;</span>34<span class="cite-bracket">&#93;</span></a></sup> <b>ERE</b> (Extended Regular Expressions), and <b>SRE</b> (Simple Regular Expressions). SRE is <a href="/wiki/Deprecation" title="Deprecation">deprecated</a>,<sup id="cite_ref-35" class="reference"><a href="#cite_note-35"><span class="cite-bracket">&#91;</span>35<span class="cite-bracket">&#93;</span></a></sup> in favor of BRE, as both provide <a href="/wiki/Backward_compatibility" title="Backward compatibility">backward compatibility</a>. The subsection below covering the <i>character classes</i> applies to both BRE and ERE. </p><p>BRE and ERE work together. ERE adds <code>?</code>, <code>+</code>, and <code>|</code>, and it removes the need to escape the metacharacters <code>(&#160;)</code> and <code>{&#160;}</code>, which are <i>required</i> in BRE. Furthermore, as long as the POSIX standard syntax for regexes is adhered to, there can be, and often is, additional syntax to serve specific (yet POSIX compliant) applications. Although POSIX.2 leaves some implementation specifics undefined, BRE and ERE provide a "standard" which has since been adopted as the default syntax of many tools, where the choice of BRE or ERE modes is usually a supported option. For example, <a href="/wiki/GNU" title="GNU">GNU</a> <code>grep</code> has the following options: "<code>grep -E</code>" for ERE, and "<code>grep -G</code>" for BRE (the default), and "<code>grep -P</code>" for <a href="/wiki/Perl" title="Perl">Perl</a> regexes. </p><p>Perl regexes have become a de facto standard, having a rich and powerful set of atomic expressions. Perl has no "basic" or "extended" levels. As in POSIX EREs, <code>(&#160;)</code> and <code>{&#160;}</code> are treated as metacharacters unless escaped; other metacharacters are known to be literal or symbolic based on context alone. Additional functionality includes <a href="#Lazy_matching">lazy matching</a>, <a href="#backreferences">backreferences</a>, named capture groups, and <a href="/wiki/Recursion_(computer_science)" title="Recursion (computer science)">recursive</a> patterns. </p> <div class="mw-heading mw-heading4"><h4 id="POSIX_basic_and_extended">POSIX basic and extended</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=11" title="Edit section: POSIX basic and extended"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the <a href="/wiki/POSIX" title="POSIX">POSIX</a> standard, Basic Regular Syntax (<b>BRE</b>) requires that the <a href="/wiki/Metacharacter" title="Metacharacter">metacharacters</a> <code>(&#160;)</code> and <code>{&#160;}</code> be designated <code>\(\)</code> and <code>\{\}</code>, whereas Extended Regular Syntax (<b>ERE</b>) does not. </p> <table class="wikitable"> <tbody><tr> <th>Metacharacter </th> <th>Description </th></tr> <tr valign="top"> <th><code>^</code> </th> <td>Matches the starting position within the string. In line-based tools, it matches the starting position of any line. </td></tr> <tr valign="top"> <th><code>.</code> </th> <td>Matches any single character (many applications exclude <a href="/wiki/Newline" title="Newline">newlines</a>, and exactly which characters are considered newlines is flavor-, character-encoding-, and platform-specific, but it is safe to assume that the line feed character is included). Within POSIX bracket expressions, the dot character matches a literal dot. For example, <code>a.c</code> matches "abc", etc., but <code>[a.c]</code> matches only "a", ".", or "c". </td></tr> <tr valign="top"> <th><code>[&#160;]</code> </th> <td>A bracket expression. Matches a single character that is contained within the brackets. For example, <code>[abc]</code> matches "a", "b", or "c". <code>[a-z]</code> specifies a range which matches any lowercase letter from "a" to "z". These forms can be mixed: <code>[abcx-z]</code> matches "a", "b", "c", "x", "y", or "z", as does <code>[a-cx-z]</code>. <p>The <code>-</code> character is treated as a literal character if it is the last or the first (after the <code>^</code>, if present) character within the brackets: <code>[abc-]</code>, <code>[-abc]</code>, <code>[^-abc]</code>. Backslash escapes are not allowed. The <code>]</code> character can be included in a bracket expression if it is the first (after the <code>^</code>, if present) character: <code>[]abc]</code>, <code>[^]abc]</code>. </p> </td></tr> <tr valign="top"> <th><code>[^&#160;]</code> </th> <td>Matches a single character that is not contained within the brackets. For example, <code>[^abc]</code> matches any character other than "a", "b", or "c". <code>[^a-z]</code> matches any single character that is not a lowercase letter from "a" to "z". Likewise, literal characters and ranges can be mixed. </td></tr> <tr valign="top"> <th><code>$</code> </th> <td>Matches the ending position of the string or the position just before a string-ending newline. In line-based tools, it matches the ending position of any line. </td></tr> <tr valign="top"> <th><code>( )</code> </th> <td>Defines a marked subexpression, also called a capturing group, which is essential for extracting the desired part of the text (See also the next entry, <code>\<i>n</i></code>). <i>BRE mode requires <span class="nowrap"><code>\(&#160;\)</code></span>.</i> </td></tr> <tr valign="top"> <th><code>\<i>n</i></code> </th> <td>Matches what the <i>n</i>th marked subexpression matched, where <i>n</i> is a digit from 1 to 9. This construct is defined in the POSIX standard.<sup id="cite_ref-36" class="reference"><a href="#cite_note-36"><span class="cite-bracket">&#91;</span>36<span class="cite-bracket">&#93;</span></a></sup> Some tools allow referencing more than nine capturing groups. Also known as a back-reference, this feature is supported in BRE mode. </td></tr> <tr valign="top"> <th><code>*</code> </th> <td>Matches the preceding element zero or more times. For example, <code>ab*c</code> matches "ac", "abc", "abbbc", etc. <code>[xyz]*</code> matches "", "x", "y", "z", "zx", "zyx", "xyzzy", and so on. <code>(ab)*</code> matches "", "ab", "abab", "ababab", and so on. </td></tr> <tr valign="top"> <th><span class="nowrap"><code>{<i>m</i>,<i>n</i>}</code></span> </th> <td>Matches the preceding element at least <i>m</i> and not more than <i>n</i> times. For example, <code>a{3,5}</code> matches only "aaa", "aaaa", and "aaaaa". This is not found in a few older instances of regexes. BRE mode requires <code><span class="nowrap">\{<i>m</i>,<i>n</i>\</span>}</code>. </td></tr></tbody></table> <p><b>Examples:</b> </p> <ul><li><code>.at</code> matches any three-character string ending with "at", including "hat", "cat", "bat", "4at", "#at" and " at" (starting with a space).</li> <li><code>[hc]at</code> matches "hat" and "cat".</li> <li><code>[^b]at</code> matches all strings matched by <code>.at</code> except "bat".</li> <li><code>[^hc]at</code> matches all strings matched by <code>.at</code> other than "hat" and "cat".</li> <li><code>^[hc]at</code> matches "hat" and "cat", but only at the beginning of the string or line.</li> <li><code>[hc]at$</code> matches "hat" and "cat", but only at the end of the string or line.</li> <li><code>\[.\]</code> matches any single character surrounded by "[" and "]" since the brackets are escaped, for example: "[a]", "[b]", "[7]", "[@]", "[]]", and "[ ]" (bracket space bracket).</li> <li><code>s.*</code> matches s followed by zero or more characters, for example: "s", "saw", "seed", "s3w96.7", and "s6#h%(&gt;&gt;&gt;m n mQ".</li></ul> <p>According to Russ Cox, the POSIX specification requires ambiguous subexpressions to be handled in a way different from Perl's. The committee replaced Perl's rules with one that is simple to explain, but the new "simple" rules are actually more complex to implement: they were incompatible with pre-existing tooling and made it essentially impossible to define a "lazy match" (see below) extension. As a result, very few programs actually implement the POSIX subexpression rules (even when they implement other parts of the POSIX syntax).<sup id="cite_ref-37" class="reference"><a href="#cite_note-37"><span class="cite-bracket">&#91;</span>37<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading4"><h4 id="Metacharacters_in_POSIX_extended">Metacharacters in POSIX extended</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=12" title="Edit section: Metacharacters in POSIX extended"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The meaning of metacharacters <a href="/wiki/Escape_character" title="Escape character">escaped</a> with a backslash is reversed for some characters in the POSIX Extended Regular Expression (<b>ERE</b>) syntax. With this syntax, a backslash causes the metacharacter to be treated as a literal character. So, for example, <code>\(&#160;\)</code> is now <code>(&#160;)</code> and <code>\{&#160;\}</code> is now <code>{&#160;}</code>. Additionally, support is removed for <code>\<i>n</i></code> backreferences and the following metacharacters are added: </p> <table class="wikitable"> <tbody><tr> <th>Metacharacter </th> <th>Description </th></tr> <tr valign="top"> <th><code>?</code> </th> <td>Matches the preceding element zero or one time. For example, <code>ab?c</code> matches only "ac" or "abc". </td></tr> <tr> <th><code>+</code> </th> <td>Matches the preceding element one or more times. For example, <code>ab+c</code> matches "abc", "abbc", "abbbc", and so on, but not "ac". </td></tr> <tr> <th><code>|</code> </th> <td>The choice (also known as alternation or set union) operator matches either the expression before or the expression after the operator. For example, <code>abc|def</code> matches "abc" or "def". </td></tr></tbody></table> <p><b>Examples:</b> </p> <ul><li><code>[hc]?at</code> matches "at", "hat", and "cat".</li> <li><code>[hc]*at</code> matches "at", "hat", "cat", "hhat", "chat", "hcat", "cchchat", and so on.</li> <li><code>[hc]+at</code> matches "hat", "cat", "hhat", "chat", "hcat", "cchchat", and so on, but not "at".</li> <li><code>cat|dog</code> matches "cat" or "dog".</li></ul> <p>POSIX Extended Regular Expressions can often be used with modern Unix utilities by including the <a href="/wiki/Command_line" class="mw-redirect" title="Command line">command line</a> flag <var>-E</var>. </p> <div class="mw-heading mw-heading4"><h4 id="Character_classes">Character classes</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=13" title="Edit section: Character classes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The character class is the most basic regex concept after a literal match. It makes one small sequence of characters match a larger set of characters. For example, <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[A-Z]</span></code> could stand for any uppercase letter in the English alphabet, and <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">d</span></code> could mean any digit. Character classes apply to both POSIX levels. </p><p>When specifying a range of characters, such as <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[a-Z]</span></code> (i.e. lowercase <i><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="nv">a</span></code></i> to uppercase <i><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="nv">Z</span></code></i>), the computer's locale settings determine the contents by the numeric ordering of the character encoding. They could store digits in that sequence, or the ordering could be <i>abc...zABC...Z</i>, or <i>aAbBcC...zZ</i>. So the POSIX standard defines a character class, which will be known by the regex processor installed. Those definitions are in the following table: </p> <table class="wikitable sortable"> <tbody><tr> <th>Description </th> <th>POSIX</th> <th>Perl/Tcl</th> <th>Vim</th> <th>Java</th> <th>ASCII </th></tr> <tr> <td>ASCII characters </td> <td> </td> <td> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">ASCII</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[\x00-\x7F]</span></code> </td></tr> <tr> <td>Alphanumeric characters </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:alnum:]</span></code> </td> <td> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Alnum</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[A-Za-z0-9]</span></code> </td></tr> <tr> <td>Alphanumeric characters plus "_" </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">w</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">w</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">w</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[A-Za-z0-9_]</span></code> </td></tr> <tr> <td>Non-word characters </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">W</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">W</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">W</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[^A-Za-z0-9_]</span></code> </td></tr> <tr> <td>Alphabetic characters </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:alpha:]</span></code> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">a</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Alpha</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[A-Za-z]</span></code> </td></tr> <tr> <td>Space and tab </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:blank:]</span></code> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">s</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Blank</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[ \t]</span></code> </td></tr> <tr> <td>Word boundaries </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">b</span></code> </td> <td><code>\&lt; \&gt;</code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">b</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="o">(?</span><span class="err">&lt;</span><span class="o">=</span><span class="err">\</span><span class="nv">W</span><span class="o">)(?=</span><span class="err">\</span><span class="nv">w</span><span class="o">)|(?</span><span class="err">&lt;</span><span class="o">=</span><span class="err">\</span><span class="nv">w</span><span class="o">)(?=</span><span class="err">\</span><span class="nv">W</span><span class="o">)</span></code> </td></tr> <tr> <td>Non-word boundaries </td> <td> </td> <td> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">B</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="o">(?</span><span class="err">&lt;</span><span class="o">=</span><span class="err">\</span><span class="nv">W</span><span class="o">)(?=</span><span class="err">\</span><span class="nv">W</span><span class="o">)|(?</span><span class="err">&lt;</span><span class="o">=</span><span class="err">\</span><span class="nv">w</span><span class="o">)(?=</span><span class="err">\</span><span class="nv">w</span><span class="o">)</span></code> </td></tr> <tr> <td><a href="/wiki/Control_character" title="Control character">Control characters</a> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:cntrl:]</span></code> </td> <td> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Cntrl</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[\x00-\x1F\x7F]</span></code> </td></tr> <tr> <td>Digits </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:digit:]</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">d</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">d</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Digit</span><span class="p">}</span></code> or <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">d</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[0-9]</span></code> </td></tr> <tr> <td>Non-digits </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">D</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">D</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">D</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[^0-9]</span></code> </td></tr> <tr> <td>Visible characters </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:graph:]</span></code> </td> <td> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Graph</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[\x21-\x7E]</span></code> </td></tr> <tr> <td>Lowercase letters </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:lower:]</span></code> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">l</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Lower</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[a-z]</span></code> </td></tr> <tr> <td>Visible characters and the space character </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:print:]</span></code> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Print</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[\x20-\x7E]</span></code> </td></tr> <tr> <td>Punctuation characters </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:punct:]</span></code> </td> <td> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Punct</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[][!&quot;#$%&amp;&#39;()*+,./:;&lt;=&gt;?@\^_`{|}~-]</span></code> </td></tr> <tr> <td><a href="/wiki/Whitespace_character" title="Whitespace character">Whitespace characters</a> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:space:]</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">s</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">_s</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Space</span><span class="p">}</span></code> or <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">s</span></code> </td> <td><code>[ <a href="/wiki/%5Ct" class="mw-redirect" title="\t">\t</a><a href="/wiki/%5Cr" class="mw-redirect" title="\r">\r</a><a href="/wiki/%5Cn" class="mw-redirect" title="\n">\n</a><a href="/wiki/%5Cv" class="mw-redirect" title="\v">\v</a><a href="/wiki/%5Cf" class="mw-redirect" title="\f">\f</a>]</code> </td></tr> <tr> <td>Non-whitespace characters </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">S</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">S</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">S</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[^ \t\r\n\v\f]</span></code> </td></tr> <tr> <td>Uppercase letters </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:upper:]</span></code> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">u</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Upper</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[A-Z]</span></code> </td></tr> <tr> <td>Hexadecimal digits </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:xdigit:]</span></code> </td> <td> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">x</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">XDigit</span><span class="p">}</span></code> </td> <td><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[A-Fa-f0-9]</span></code> </td></tr></tbody></table> <p>POSIX character classes can only be used within bracket expressions. For example, <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[[:upper:]</span><span class="nv">ab</span><span class="err">]</span></code> matches the uppercase letters and lowercase "a" and "b". </p><p>An additional non-POSIX class understood by some tools is <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:word:]</span></code>, which is usually defined as <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[:alnum:]</span></code> plus underscore. This reflects the fact that in many programming languages these are the characters that may be used in identifiers. The editor <a href="/wiki/Vim_(text_editor)" title="Vim (text editor)">Vim</a> further distinguishes <i>word</i> and <i>word-head</i> classes (using the notation <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">w</span></code> and <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">h</span></code>) since in many programming languages the characters that can begin an identifier are not the same as those that can occur in other positions: numbers are generally excluded, so an identifier would look like <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">h</span><span class="err">\</span><span class="nv">w</span><span class="o">*</span></code> or <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="s">[[:alpha:]</span><span class="nv">_</span><span class="err">]</span><span class="s">[[:alnum:]</span><span class="nv">_</span><span class="err">]</span><span class="o">*</span></code> in POSIX notation. </p><p>Note that what the POSIX regex standards call <i>character classes</i> are commonly referred to as <i>POSIX character classes</i> in other regex flavors which support them. With most other regex flavors, the term <i>character class</i> is used to describe what POSIX calls <i>bracket expressions</i>. </p> <div class="mw-heading mw-heading3"><h3 id="Perl_and_PCRE">Perl and PCRE</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=14" title="Edit section: Perl and PCRE"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951"><div role="note" class="hatnote navigation-not-searchable">See also: <a href="/wiki/Perl_Compatible_Regular_Expressions" title="Perl Compatible Regular Expressions">Perl Compatible Regular Expressions</a></div> <p>Because of its expressive power and (relative) ease of reading, many other utilities and programming languages have adopted syntax similar to <a href="/wiki/Perl" title="Perl">Perl</a>'s—for example, <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a>, <a href="/wiki/JavaScript" title="JavaScript">JavaScript</a>, <a href="/wiki/Julia_(programming_language)" title="Julia (programming language)">Julia</a>, <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, <a href="/wiki/Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a>, <a href="/wiki/Qt_(software)" title="Qt (software)">Qt</a>, Microsoft's <a href="/wiki/.NET_Framework" title=".NET Framework">.NET Framework</a>, and <a href="/wiki/XML_Schema_(W3C)" title="XML Schema (W3C)">XML Schema</a>. Some languages and tools such as <a href="/wiki/Boost_C%2B%2B_Libraries" class="mw-redirect" title="Boost C++ Libraries">Boost</a> and <a href="/wiki/PHP" title="PHP">PHP</a> support multiple regex flavors. Perl-derivative regex implementations are not identical and usually implement a subset of features found in Perl 5.0, released in 1994. Perl sometimes does incorporate features initially found in other languages. For example, Perl 5.10 implements syntactic extensions originally developed in PCRE and Python.<sup id="cite_ref-38" class="reference"><a href="#cite_note-38"><span class="cite-bracket">&#91;</span>38<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Lazy_matching">Lazy matching</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=15" title="Edit section: Lazy matching"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In Python and some other implementations (e.g. Java), the three common quantifiers (<code>*</code>, <code>+</code> and <code>?</code>) are <a href="/wiki/Greedy_algorithm" title="Greedy algorithm">greedy</a> by default because they match as many characters as possible.<sup id="cite_ref-py-re_39-0" class="reference"><a href="#cite_note-py-re-39"><span class="cite-bracket">&#91;</span>39<span class="cite-bracket">&#93;</span></a></sup> The regex <code>".+"</code> (including the double-quotes) applied to the string </p><p>"Ganymede," he continued, "is the largest moon in the Solar System." </p><p>matches the entire line (because the entire line begins and ends with a double-quote) instead of matching only the first part, <code>"Ganymede,"</code>. The aforementioned quantifiers may, however, be made <i>lazy</i> or <i>minimal</i> or <i>reluctant</i>, matching as few characters as possible, by appending a question mark: <code>".+?"</code> matches only <code>"Ganymede,"</code>.<sup id="cite_ref-py-re_39-1" class="reference"><a href="#cite_note-py-re-39"><span class="cite-bracket">&#91;</span>39<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Possessive_matching">Possessive matching</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=16" title="Edit section: Possessive matching"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In Java and Python 3.11+,<sup id="cite_ref-40" class="reference"><a href="#cite_note-40"><span class="cite-bracket">&#91;</span>40<span class="cite-bracket">&#93;</span></a></sup> quantifiers may be made <i>possessive</i> by appending a plus sign, which disables backing off (in a backtracking engine), even if doing so would allow the overall match to succeed:<sup id="cite_ref-es-re_41-0" class="reference"><a href="#cite_note-es-re-41"><span class="cite-bracket">&#91;</span>41<span class="cite-bracket">&#93;</span></a></sup> While the regex <code>".*"</code> applied to the string </p><p>"Ganymede," he continued, "is the largest moon in the Solar System." </p><p>matches the entire line, the regex <code>".*+"</code> does <em>not match at all</em>, because <code>.*+</code> consumes the entire input, including the final <code>"</code>. Thus, possessive quantifiers are most useful with negated character classes, e.g. <code>"[^"]*+"</code>, which matches <code>"Ganymede,"</code> when applied to the same string. </p><p>Another common extension serving the same function is atomic grouping, which disables backtracking for a parenthesized group. The typical syntax is <style data-mw-deduplicate="TemplateStyles:r886049734">.mw-parser-output .monospaced{font-family:monospace,monospace}</style><span class="monospaced">(?&gt;group)</span>. For example, while <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">^(wi|w)i$</span> matches both <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">wi</span> and <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">wii</span>, <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">^(?&gt;wi|w)i$</span> only matches <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">wii</span> because the engine is forbidden from backtracking and so cannot try setting the group to "w" after matching "wi".<sup id="cite_ref-42" class="reference"><a href="#cite_note-42"><span class="cite-bracket">&#91;</span>42<span class="cite-bracket">&#93;</span></a></sup> </p><p>Possessive quantifiers are easier to implement than greedy and lazy quantifiers, and are typically more efficient at runtime.<sup id="cite_ref-es-re_41-1" class="reference"><a href="#cite_note-es-re-41"><span class="cite-bracket">&#91;</span>41<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="IETF_I-Regexp">IETF I-Regexp</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=17" title="Edit section: IETF I-Regexp"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>IETF RFC 9485 describes "I-Regexp: An Interoperable Regular Expression Format". It specifies a limited subset of regular-expression idioms designed to be interoperable, i.e. produce the same effect, in a large number of regular-expression libraries. I-Regexp is also limited to matching, i.e. providing a true or false match between a regular expression and a given piece of text. Thus, it lacks advanced features such as capture groups, lookahead, and backreferences.<sup id="cite_ref-43" class="reference"><a href="#cite_note-43"><span class="cite-bracket">&#91;</span>43<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Patterns_for_non-regular_languages">Patterns for non-regular languages</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=18" title="Edit section: Patterns for non-regular languages"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Many features found in virtually all modern regular expression libraries provide an expressive power that exceeds the <a href="/wiki/Regular_language" title="Regular language">regular languages</a>. For example, many implementations allow grouping subexpressions with parentheses and recalling the value they match in the same expression (<i><style data-mw-deduplicate="TemplateStyles:r1238216509">.mw-parser-output .vanchor>:target~.vanchor-text{background-color:#b1d2ff}@media screen{html.skin-theme-clientpref-night .mw-parser-output .vanchor>:target~.vanchor-text{background-color:#0f4dc9}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .vanchor>:target~.vanchor-text{background-color:#0f4dc9}}</style><span class="vanchor"><span id="backreferences"></span><span class="vanchor-text">backreferences</span></span></i>). This means that, among other things, a pattern can match strings of repeated words like "papa" or "WikiWiki", called <i>squares</i> in formal language theory. The pattern for these strings is <code>(.+)\1</code>. </p><p>The language of squares is not regular, nor is it <a href="/wiki/Context-free_language" title="Context-free language">context-free</a>, due to the <a href="/wiki/Pumping_lemma_for_context-free_languages" title="Pumping lemma for context-free languages">pumping lemma</a>. However, <a href="/wiki/Pattern_matching" title="Pattern matching">pattern matching</a> with an unbounded number of backreferences, as supported by numerous modern tools, is still <a href="/wiki/Context-sensitive_language" title="Context-sensitive language">context sensitive</a>.<sup id="cite_ref-44" class="reference"><a href="#cite_note-44"><span class="cite-bracket">&#91;</span>44<span class="cite-bracket">&#93;</span></a></sup> The general problem of matching any number of backreferences is <a href="/wiki/NP-complete" class="mw-redirect" title="NP-complete">NP-complete</a>, and the execution time for known algorithms grows exponentially by the number of backreference groups used.<sup id="cite_ref-45" class="reference"><a href="#cite_note-45"><span class="cite-bracket">&#91;</span>45<span class="cite-bracket">&#93;</span></a></sup> </p><p>However, many tools, libraries, and engines that provide such constructions still use the term <i>regular expression</i> for their patterns. This has led to a nomenclature where the term regular expression has different meanings in <a href="/wiki/Formal_language" title="Formal language">formal language theory</a> and pattern matching. For this reason, some people have taken to using the term <i>regex</i>, <i>regexp</i>, or simply <i>pattern</i> to describe the latter. <a href="/wiki/Larry_Wall" title="Larry Wall">Larry Wall</a>, author of the Perl programming language, writes in an essay about the design of Raku: </p> <style data-mw-deduplicate="TemplateStyles:r1244412712">.mw-parser-output .templatequote{overflow:hidden;margin:1em 0;padding:0 32px}.mw-parser-output .templatequotecite{line-height:1.5em;text-align:left;margin-top:0}@media(min-width:500px){.mw-parser-output .templatequotecite{padding-left:1.6em}}</style><blockquote class="templatequote"><p>"Regular expressions" […] are only marginally related to real regular expressions. Nevertheless, the term has grown with the capabilities of our pattern matching engines, so I'm not going to try to fight linguistic necessity here. I will, however, generally call them "regexes" (or "regexen", when I'm in an Anglo-Saxon mood).<sup id="cite_ref-Apocalypse5_19-1" class="reference"><a href="#cite_note-Apocalypse5-19"><span class="cite-bracket">&#91;</span>19<span class="cite-bracket">&#93;</span></a></sup></p></blockquote> <div class="mw-heading mw-heading3"><h3 id="Assertions">Assertions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=19" title="Edit section: Assertions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <table id="lookbehind" class="floatright wikitable"> <tbody><tr> <th>Assertion</th> <th>Lookbehind</th> <th>Lookahead </th></tr> <tr> <th>Positive </th> <td style="text-align:center;font-size:125%;"><code>(?<b>&lt;=</b><span style="display:inline;border-style: solid;padding: 0 0.5ex;border-color: black;border-width: 0px;background-color: black;color: white;font-size: 80%;margin: 3px;border-radius:1ex;">pattern</span>)</code> </td> <td style="text-align:center;font-size:125%;"><code>(?<b>=</b><span style="display:inline;border-style: solid;padding: 0 0.5ex;border-color: black;border-width: 0px;background-color: black;color: white;font-size: 80%;margin: 3px;border-radius:1ex;">pattern</span>)</code> </td></tr> <tr> <th>Negative </th> <td style="text-align:center;font-size:125%;"><code>(?<b>&lt;!</b><span style="display:inline;border-style: solid;padding: 0 0.5ex;border-color: black;border-width: 0px;background-color: black;color: white;font-size: 80%;margin: 3px;border-radius:1ex;">pattern</span>)</code> </td> <td style="text-align:center;font-size:125%;"><code>(?<span style="padding:1px;"><b>!</b></span><span style="display:inline;border-style: solid;padding: 0 0.5ex;border-color: black;border-width: 0px;background-color: black;color: white;font-size: 80%;margin: 3px;border-radius:1ex;">pattern</span>)</code> </td></tr> <tr> <td colspan="3">Look-behind and look-ahead assertions<br />in <a href="/wiki/Perl" title="Perl">Perl</a> regular expressions </td></tr></tbody></table> <p>Other features not found in describing regular languages include assertions. These include the ubiquitous <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">^</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">$</code>, used since at least 1970,<sup id="cite_ref-46" class="reference"><a href="#cite_note-46"><span class="cite-bracket">&#91;</span>46<span class="cite-bracket">&#93;</span></a></sup> as well as some more sophisticated extensions like lookaround that appeared in 1994.<sup id="cite_ref-perl5_47-0" class="reference"><a href="#cite_note-perl5-47"><span class="cite-bracket">&#91;</span>47<span class="cite-bracket">&#93;</span></a></sup> Lookarounds define the surrounding of a match and do not spill into the match itself, a feature only relevant for the use case of string searching.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">&#91;<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (June 2023)">citation needed</span></a></i>&#93;</sup> Some of them can be simulated in a regular language by treating the surroundings as a part of the language as well.<sup id="cite_ref-48" class="reference"><a href="#cite_note-48"><span class="cite-bracket">&#91;</span>48<span class="cite-bracket">&#93;</span></a></sup> </p><p>The <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238216509"><span class="vanchor"><span id="look-ahead_assertions"></span><span class="vanchor-text">look-ahead assertions</span></span> <span class="nowrap"><code>(?=...)</code></span> and <span class="nowrap"><code>(?!...)</code></span> have been attested since at least 1994, starting with Perl 5.<sup id="cite_ref-perl5_47-1" class="reference"><a href="#cite_note-perl5-47"><span class="cite-bracket">&#91;</span>47<span class="cite-bracket">&#93;</span></a></sup> The look-behind assertions <span class="nowrap"><code>(?&lt;=...)</code></span> and <span class="nowrap"><code>(?&lt;!...)</code></span> are attested since 1997 in a commit by Ilya Zakharevich to Perl 5.005.<sup id="cite_ref-49" class="reference"><a href="#cite_note-49"><span class="cite-bracket">&#91;</span>49<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Implementations_and_running_times">Implementations and running times <span class="anchor" id="Implementations"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=20" title="Edit section: Implementations and running times"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>There are at least three different <a href="/wiki/Algorithm" title="Algorithm">algorithms</a> that decide whether and how a given regex matches a string. </p><p>The oldest and fastest relies on a result in formal language theory that allows every <a href="/wiki/Nondeterministic_finite_automaton" title="Nondeterministic finite automaton">nondeterministic finite automaton</a> (NFA) to be transformed into a <a href="/wiki/Deterministic_finite_automaton" title="Deterministic finite automaton">deterministic finite automaton</a> (DFA). The DFA can be constructed explicitly and then run on the resulting input string one symbol at a time. Constructing the DFA for a regular expression of size <i>m</i> has the time and memory cost of <a href="/wiki/Big_O_notation" title="Big O notation"><i>O</i></a>(2<sup><i>m</i></sup>), but it can be run on a string of size <i>n</i> in time <i>O</i>(<i>n</i>). Note that the size of the expression is the size after abbreviations, such as numeric quantifiers, have been expanded. </p><p>An alternative approach is to simulate the NFA directly, essentially building each DFA state on demand and then discarding it at the next step. This keeps the DFA implicit and avoids the exponential construction cost, but running cost rises to <i>O</i>(<i>mn</i>). The explicit approach is called the DFA algorithm and the implicit approach the NFA algorithm. Adding caching to the NFA algorithm is often called the "lazy DFA" algorithm, or just the DFA algorithm without making a distinction. These algorithms are fast, but using them for recalling grouped subexpressions, lazy quantification, and similar features is tricky.<sup id="cite_ref-50" class="reference"><a href="#cite_note-50"><span class="cite-bracket">&#91;</span>50<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-51" class="reference"><a href="#cite_note-51"><span class="cite-bracket">&#91;</span>51<span class="cite-bracket">&#93;</span></a></sup> Modern implementations include the re1-<a href="/wiki/RE2_(software)" title="RE2 (software)">re2</a>-sregex family based on Cox's code. </p><p>The third algorithm is to match the pattern against the input string by <a href="/wiki/Backtracking" title="Backtracking">backtracking</a>. This algorithm is commonly called NFA, but this terminology can be confusing. Its running time can be exponential, which simple implementations exhibit when matching against expressions like <code class="mw-highlight mw-highlight-lang-perl mw-content-ltr" style="" dir="ltr"><span class="p">(</span><span class="n">a</span><span class="o">|</span><span class="n">aa</span><span class="p">)</span><span class="o">*</span><span class="n">b</span></code> that contain both alternation and unbounded quantification and force the algorithm to consider an exponentially increasing number of sub-cases. This behavior can cause a security problem called <a href="/wiki/Regular_expression_Denial_of_Service" class="mw-redirect" title="Regular expression Denial of Service">Regular expression Denial of Service</a> (ReDoS). </p><p>Although backtracking implementations only give an exponential guarantee in the worst case, they provide much greater flexibility and expressive power. For example, any implementation which allows the use of backreferences, or implements the various extensions introduced by Perl, must include some kind of backtracking. Some implementations try to provide the best of both algorithms by first running a fast DFA algorithm, and revert to a potentially slower backtracking algorithm only when a backreference is encountered during the match. GNU grep (and the underlying gnulib DFA) uses such a strategy.<sup id="cite_ref-52" class="reference"><a href="#cite_note-52"><span class="cite-bracket">&#91;</span>52<span class="cite-bracket">&#93;</span></a></sup> </p><p>Sublinear runtime algorithms have been achieved using <a href="/wiki/Boyer%E2%80%93Moore_string-search_algorithm" title="Boyer–Moore string-search algorithm">Boyer-Moore (BM) based algorithms</a> and related DFA optimization techniques such as the reverse scan.<sup id="cite_ref-53" class="reference"><a href="#cite_note-53"><span class="cite-bracket">&#91;</span>53<span class="cite-bracket">&#93;</span></a></sup> GNU grep, which supports a wide variety of POSIX syntaxes and extensions, uses BM for a first-pass prefiltering, and then uses an implicit DFA. Wu <a href="/wiki/Agrep" title="Agrep">agrep</a>, which implements approximate matching, combines the prefiltering into the DFA in BDM (backward DAWG matching). NR-grep's BNDM extends the BDM technique with Shift-Or bit-level parallelism.<sup id="cite_ref-54" class="reference"><a href="#cite_note-54"><span class="cite-bracket">&#91;</span>54<span class="cite-bracket">&#93;</span></a></sup> </p><p>A few theoretical alternatives to backtracking for backreferences exist, and their "exponents" are tamer in that they are only related to the number of backreferences, a fixed property of some regexp languages such as POSIX. One naive method that duplicates a non-backtracking NFA for each backreference note has a complexity of <span class="nowrap">&#8288;<span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\mathrm {O} }(n^{2k+2})}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="normal">O</mi> </mrow> </mrow> <mo stretchy="false">(</mo> <msup> <mi>n</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> <mi>k</mi> <mo>+</mo> <mn>2</mn> </mrow> </msup> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\mathrm {O} }(n^{2k+2})}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/361c3d5a02535be4d1eadd7ff71c859ce4aab804" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:9.023ex; height:3.176ex;" alt="{\displaystyle {\mathrm {O} }(n^{2k+2})}"></span>&#8288;</span> time and <span class="nowrap">&#8288;<span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\mathrm {O} }(n^{2k+1})}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="normal">O</mi> </mrow> </mrow> <mo stretchy="false">(</mo> <msup> <mi>n</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> <mi>k</mi> <mo>+</mo> <mn>1</mn> </mrow> </msup> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\mathrm {O} }(n^{2k+1})}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/422ccb4d3778a47ae05dff4c03e335ba8c12fe8b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:9.023ex; height:3.176ex;" alt="{\displaystyle {\mathrm {O} }(n^{2k+1})}"></span>&#8288;</span> space for a haystack of length n and k backreferences in the RegExp.<sup id="cite_ref-55" class="reference"><a href="#cite_note-55"><span class="cite-bracket">&#91;</span>55<span class="cite-bracket">&#93;</span></a></sup> A very recent theoretical work based on memory automata gives a tighter bound based on "active" variable nodes used, and a polynomial possibility for some backreferenced regexps.<sup id="cite_ref-56" class="reference"><a href="#cite_note-56"><span class="cite-bracket">&#91;</span>56<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Unicode">Unicode</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=21" title="Edit section: Unicode"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In theoretical terms, any token set can be matched by regular expressions as long as it is pre-defined. In terms of historical implementations, regexes were originally written to use <a href="/wiki/American_Standard_Code_for_Information_Interchange" class="mw-redirect" title="American Standard Code for Information Interchange">ASCII</a> characters as their token set though regex libraries have supported numerous other <a href="/wiki/Character_set" class="mw-redirect" title="Character set">character sets</a>. Many modern regex engines offer at least some support for <a href="/wiki/Unicode" title="Unicode">Unicode</a>. In most respects it makes no difference what the character set is, but some issues do arise when extending regexes to support Unicode. </p> <ul><li><b>Supported encoding</b>. Some regex libraries expect to work on some particular encoding instead of on abstract Unicode characters. Many of these require the <a href="/wiki/UTF-8" title="UTF-8">UTF-8</a> encoding, while others might expect <a href="/wiki/UTF-16" title="UTF-16">UTF-16</a>, or <a href="/wiki/UTF-32" title="UTF-32">UTF-32</a>. In contrast, Perl and Java are agnostic on encodings, instead operating on decoded characters internally.</li> <li><b>Supported Unicode range</b>. Many regex engines support only the <a href="/wiki/Basic_Multilingual_Plane" class="mw-redirect" title="Basic Multilingual Plane">Basic Multilingual Plane</a>, that is, the characters which can be encoded with only 16 bits. Currently (as of 2016<sup class="plainlinks noexcerpt noprint asof-tag update" style="display:none;"><a class="external text" href="https://en.wikipedia.org/w/index.php?title=Regular_expression&amp;action=edit">&#91;update&#93;</a></sup>) only a few regex engines (e.g., Perl's and Java's) can handle the full 21-bit Unicode range.</li> <li><b>Extending ASCII-oriented constructs to Unicode</b>. For example, in ASCII-based implementations, character ranges of the form <code>[x-y]</code> are valid wherever <i>x</i> and <i>y</i> have <a href="/wiki/Code_point" title="Code point">code points</a> in the range [0x00,0x7F] and codepoint(<i>x</i>) ≤ codepoint(<i>y</i>). The natural extension of such character ranges to Unicode would simply change the requirement that the endpoints lie in [0x00,0x7F] to the requirement that they lie in [0x0000,0x10FFFF]. However, in practice this is often not the case. Some implementations, such as that of <a href="/wiki/Gawk_(GNU_package)" class="mw-redirect" title="Gawk (GNU package)">gawk</a>, do not allow character ranges to cross Unicode blocks. A range like [0x61,0x7F] is valid since both endpoints fall within the Basic Latin block, as is [0x0530,0x0560] since both endpoints fall within the Armenian block, but a range like [0x0061,0x0532] is invalid since it includes multiple Unicode blocks. Other engines, such as that of the <a href="/wiki/Vim_(text_editor)" title="Vim (text editor)">Vim</a> editor, allow block-crossing but the character values must not be more than 256 apart.<sup id="cite_ref-57" class="reference"><a href="#cite_note-57"><span class="cite-bracket">&#91;</span>57<span class="cite-bracket">&#93;</span></a></sup></li> <li><b>Case insensitivity</b>. Some case-insensitivity flags affect only the ASCII characters. Other flags affect all characters. Some engines have two different flags, one for ASCII, the other for Unicode. Exactly which characters belong to the POSIX classes also varies.</li> <li><b>Cousins of case insensitivity</b>. As ASCII has case distinction, case insensitivity became a logical feature in text searching. Unicode introduced alphabetic scripts without case like <a href="/wiki/Devan%C4%81gar%C4%AB" class="mw-redirect" title="Devanāgarī">Devanagari</a>. For these, <a href="/wiki/Case_sensitivity" title="Case sensitivity">case sensitivity</a> is not applicable. For scripts like Chinese, another distinction seems logical: between traditional and simplified. In Arabic scripts, insensitivity to <a href="/wiki/IMFI" title="IMFI">initial, medial, final, and isolated position</a> may be desired. In Japanese, insensitivity between <a href="/wiki/Hiragana" title="Hiragana">hiragana</a> and <a href="/wiki/Katakana" title="Katakana">katakana</a> is sometimes useful.</li> <li><b>Normalization</b>. Unicode has <a href="/wiki/Unicode#Combining_characters" title="Unicode">combining characters</a>. Like old typewriters, plain base characters (white spaces, punctuation characters, symbols, digits, or letters) can be followed by one or more non-spacing symbols (usually diacritics, like accent marks modifying letters) to form a single printable character; but Unicode also provides a limited set of precomposed characters, i.e. characters that already include one or more combining characters. A sequence of a base character + combining characters should be matched with the identical single precomposed character (only some of these combining sequences can be precomposed into a single Unicode character, but infinitely many other combining sequences are possible in Unicode, and needed for various languages, using one or more combining characters after an initial base character; these combining sequences <i>may</i> include a base character or combining characters partially precomposed, but not necessarily in canonical order and not necessarily using the canonical precompositions). The process of standardizing sequences of a base character + combining characters by decomposing these <i>canonically equivalent</i> sequences, before reordering them into canonical order (and optionally recomposing <i>some</i> combining characters into the leading base character) is called normalization.</li> <li><b>New control codes</b>. Unicode introduced, among other codes, <a href="/wiki/Byte_order_mark" title="Byte order mark">byte order marks</a> and text direction markers. These codes might have to be dealt with in a special way.</li> <li><b>Introduction of character classes for Unicode blocks, scripts, and numerous other character properties</b>. Block properties are much less useful than script properties, because a block can have code points from several different scripts, and a script can have code points from several different blocks.<sup id="cite_ref-unicode_58-0" class="reference"><a href="#cite_note-unicode-58"><span class="cite-bracket">&#91;</span>58<span class="cite-bracket">&#93;</span></a></sup> In <a href="/wiki/Perl" title="Perl">Perl</a> and the <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/regex/package-summary.html">java.util.regex</a></code> library, properties of the form <code>\p{InX}</code> or <code>\p{Block=X}</code> match characters in block <i>X</i> and <code>\P{InX}</code> or <code>\P{Block=X}</code> matches code points not in that block. Similarly, <code>\p{Armenian}</code>, <code>\p{IsArmenian}</code>, or <code>\p{Script=Armenian}</code> matches any character in the Armenian script. In general, <code>\p{X}</code> matches any character with either the binary property <i>X</i> or the general category <i>X</i>. For example, <code>\p{Lu}</code>, <code>\p{Uppercase_Letter}</code>, or <code>\p{GC=Lu}</code> matches any uppercase letter. Binary properties that are <i>not</i> general categories include <code>\p{White_Space}</code>, <code>\p{Alphabetic}</code>, <code>\p{Math}</code>, and <code>\p{Dash}</code>. Examples of non-binary properties are <code>\p{Bidi_Class=Right_to_Left}</code>, <code>\p{Word_Break=A_Letter}</code>, and <code>\p{Numeric_Value=10}</code>.</li></ul> <div class="mw-heading mw-heading2"><h2 id="Language_support">Language support</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=22" title="Edit section: Language support"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most <a href="/wiki/General-purpose_programming_language" title="General-purpose programming language">general-purpose programming languages</a> support regex capabilities, either natively or via <a href="/wiki/Library_(computing)" title="Library (computing)">libraries</a>. </p> <div class="mw-heading mw-heading2"><h2 id="Uses">Uses</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=23" title="Edit section: Uses"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Screenshot_of_MediaWiki_Blacklist.png" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/3/32/Screenshot_of_MediaWiki_Blacklist.png/220px-Screenshot_of_MediaWiki_Blacklist.png" decoding="async" width="220" height="148" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/32/Screenshot_of_MediaWiki_Blacklist.png/330px-Screenshot_of_MediaWiki_Blacklist.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/3/32/Screenshot_of_MediaWiki_Blacklist.png/440px-Screenshot_of_MediaWiki_Blacklist.png 2x" data-file-width="2359" data-file-height="1585" /></a><figcaption><a href="/wiki/MediaWiki:Titleblacklist" title="MediaWiki:Titleblacklist">A blacklist</a> on <a href="/wiki/Wikipedia" title="Wikipedia">Wikipedia</a> which uses regular expressions to identify bad titles</figcaption></figure> <p>Regexes are useful in a wide variety of text processing tasks, and more generally <a href="/wiki/String_processing" class="mw-redirect" title="String processing">string processing</a>, where the data need not be textual. Common applications include <a href="/wiki/Data_validation" title="Data validation">data validation</a>, <a href="/wiki/Data_scraping" title="Data scraping">data scraping</a> (especially <a href="/wiki/Web_scraping" title="Web scraping">web scraping</a>), <a href="/wiki/Data_wrangling" title="Data wrangling">data wrangling</a>, simple <a href="/wiki/Parsing" title="Parsing">parsing</a>, the production of <a href="/wiki/Syntax_highlighting" title="Syntax highlighting">syntax highlighting</a> systems, and many other tasks. </p><p>Some high-end <a href="/wiki/Desktop_publishing" title="Desktop publishing">desktop publishing</a> software has the ability to use regexes to automatically apply text styling, saving the person doing the layout from laboriously doing this by hand for anything that can be matched by a regex. For example, by defining a <a href="/wiki/Style_sheet_(desktop_publishing)" title="Style sheet (desktop publishing)">character style</a> that makes text into <a href="/wiki/Small_caps" title="Small caps">small caps</a> and then using the regex <code>[A-Z]{4,}</code> to apply that style, any word of four or more consecutive capital letters will be automatically rendered as small caps instead. </p><p>While regexes would be useful on Internet <a href="/wiki/Search_engine_(computing)" title="Search engine (computing)">search engines</a>, processing them across the entire database could consume excessive computer resources depending on the complexity and design of the regex. Although in many cases system administrators can run regex-based queries internally, most search engines do not offer regex support to the public. Notable exceptions include <a href="/wiki/Google_Code_Search" title="Google Code Search">Google Code Search</a> and <a href="/wiki/Exalead" title="Exalead">Exalead</a>. However, Google Code Search was shut down in January 2012.<sup id="cite_ref-59" class="reference"><a href="#cite_note-59"><span class="cite-bracket">&#91;</span>59<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Examples">Examples</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=24" title="Edit section: Examples"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The specific syntax rules vary depending on the specific implementation, <a href="/wiki/Programming_language" title="Programming language">programming language</a>, or <a href="/wiki/Library_(computing)" title="Library (computing)">library</a> in use. Additionally, the functionality of regex implementations can vary between <a href="/wiki/Software_versioning" title="Software versioning">versions</a>. </p><p>Because regexes can be difficult to both explain and understand without examples, interactive websites for testing regexes are a useful resource for learning regexes by experimentation. This section provides a basic description of some of the properties of regexes by way of illustration. </p><p>The following conventions are used in the examples.<sup id="cite_ref-clarify000_60-0" class="reference"><a href="#cite_note-clarify000-60"><span class="cite-bracket">&#91;</span>60<span class="cite-bracket">&#93;</span></a></sup> </p> <pre>metacharacter(s)&#160;;; the metacharacters column specifies the regex syntax being demonstrated =~ m// &#160;;; indicates a regex <i>match</i> operation in Perl =~ s/// &#160;;; indicates a regex <i>substitution</i> operation in Perl </pre> <p>These regexes are all Perl-like syntax. Standard <a href="#POSIX_Basic_Regular_Expressions">POSIX</a> regular expressions are different. </p><p>Unless otherwise indicated, the following examples conform to the <a href="/wiki/Perl" title="Perl">Perl</a> programming language, release 5.8.8, January 31, 2006. This means that other implementations may lack support for some parts of the syntax shown here (e.g. basic vs. extended regex, <code>\( \)</code> vs. <code>()</code>, or lack of <code>\d</code> instead of <a href="/wiki/POSIX" title="POSIX">POSIX</a> <code>[:digit:]</code>). </p><p>The syntax and conventions used in these examples coincide with that of other programming environments as well.<sup id="cite_ref-61" class="reference"><a href="#cite_note-61"><span class="cite-bracket">&#91;</span>61<span class="cite-bracket">&#93;</span></a></sup> </p> <table class="wikitable"> <tbody><tr> <th>Meta&#173;character(s) </th> <th>Description </th> <th>Example<sup id="cite_ref-62" class="reference"><a href="#cite_note-62"><span class="cite-bracket">&#91;</span>62<span class="cite-bracket">&#93;</span></a></sup> </th></tr> <tr> <th><code>.</code> </th> <td>Normally matches any character except a newline. <br />Within square brackets the dot is literal. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/...../</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 has length &gt;= 5.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello World</span> <span class="go"> has length &gt;= 5.</span> </pre></div> </td></tr> <tr> <th><code>( )</code> </th> <td>Groups a series of pattern elements to a single element. <br />When you match a pattern within parentheses, you can use any of <code>$1</code>, <code>$2</code>, ... later to refer to the previously matched pattern. Some implementations may use a backslash notation instead, like <code>\1</code>, <code>\2</code>. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/(H..).(o..)/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;We matched &#39;$1&#39; and &#39;$2&#39;.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">We matched &#39;Hel&#39; and &#39;o W&#39;.</span> </pre></div> </td></tr> <tr> <th><code>+</code> </th> <td>Matches the preceding pattern element one or more times. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/l+/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;There are one or more consecutive letter \&quot;l\&quot;&#39;s in $string1.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">There are one or more consecutive letter &quot;l&quot;&#39;s in Hello World.</span> </pre></div> </td></tr> <tr> <th><code>?</code> </th> <td>Matches the preceding pattern element zero or one time. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/H.?e/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;There is an &#39;H&#39; and a &#39;e&#39; separated by &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;0-1 characters (e.g., He Hue Hee).\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">There is an &#39;H&#39; and a &#39;e&#39; separated by 0-1 characters (e.g., He Hue Hee).</span> </pre></div> </td></tr> <tr> <th><code>?</code> </th> <td>Modifies the <code>*</code>, <code>+</code>, <code>?</code> or <code>{M,N}</code>'d regex that comes before to match as few times as possible. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/(l.+?o)/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;The non-greedy match with &#39;l&#39; followed by one or &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;more characters is &#39;llo&#39; rather than &#39;llo Wo&#39;.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">The non-greedy match with &#39;l&#39; followed by one or more characters is &#39;llo&#39; rather than &#39;llo Wo&#39;.</span> </pre></div> </td></tr> <tr> <th><code>*</code> </th> <td>Matches the preceding pattern element zero or more times. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/el*o/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;There is an &#39;e&#39; followed by zero to many &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;&#39;l&#39; followed by &#39;o&#39; (e.g., eo, elo, ello, elllo).\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">There is an &#39;e&#39; followed by zero to many &#39;l&#39; followed by &#39;o&#39; (e.g., eo, elo, ello, elllo).</span> </pre></div> </td></tr> <tr> <th><code>{M,N}</code> </th> <td>Denotes the minimum M and the maximum N match count.<br />N can be omitted and M can be 0: <code>{M}</code> matches "exactly" M times; <code>{M,}</code> matches "at least" M times; <code>{0,N}</code> matches "at most" N times.<br /><code>x* y+ z?</code> is thus equivalent to <code>x{0,} y{1,} z{0,1}</code>. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/l{1,2}/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;There exists a substring with at least 1 &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;and at most 2 l&#39;s in $string1\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">There exists a substring with at least 1 and at most 2 l&#39;s in Hello World</span> </pre></div> </td></tr> <tr> <th><code>[…]</code> </th> <td>Denotes a set of possible character matches. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/[aeiou]+/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 contains one or more vowels.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello World</span> <span class="go"> contains one or more vowels.</span> </pre></div> </td></tr> <tr> <th><code>|</code> </th> <td>Separates alternate possibilities. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/(Hello|Hi|Pogo)/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 contains at least one of Hello, Hi, or Pogo.&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello World</span> <span class="go"> contains at least one of Hello, Hi, or Pogo.</span> </pre></div> </td></tr> <tr> <th><code>\b</code> </th> <td>Matches a zero-width boundary between a word-class character (see next) and either a non-word class character or an edge; same as <p><code>(^\w|\w$|\W\w|\w\W)</code>. </p> </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/llo\b/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;There is a word that ends with &#39;llo&#39;.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">There is a word that ends with &#39;llo&#39;.</span> </pre></div> </td></tr> <tr> <th><code>\w</code> </th> <td>Matches an alphanumeric character, including "_"; <br />same as <code>[A-Za-z0-9_]</code> in ASCII, and <dl><dd><code>[\p{Alphabetic}<wbr />\p{GC=Mark}<wbr />\p{GC=Decimal_Number}<wbr />\p{GC=Connector_Punctuation}]</code></dd></dl> <p>in Unicode,<sup id="cite_ref-unicode_58-1" class="reference"><a href="#cite_note-unicode-58"><span class="cite-bracket">&#91;</span>58<span class="cite-bracket">&#93;</span></a></sup> where the <code>Alphabetic</code> property contains more than Latin letters, and the <code>Decimal_Number</code> property contains more than Arab digits. </p> </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/\w/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;There is at least one alphanumeric &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;character in $string1 (A-Z, a-z, 0-9, _).\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">There is at least one alphanumeric character in Hello World</span> <span class="go"> (A-Z, a-z, 0-9, _).</span> </pre></div> </td></tr> <tr> <th><code>\W</code> </th> <td>Matches a <i>non</i>-alphanumeric character, excluding "_"; <br />same as <code>[^A-Za-z0-9_]</code> in ASCII, and <dl><dd><code>[^\p{Alphabetic}<wbr />\p{GC=Mark}<wbr />\p{GC=Decimal_Number}<wbr />\p{GC=Connector_Punctuation}]</code></dd></dl> <p>in Unicode. </p> </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/\W/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;The space between Hello and &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;World is not alphanumeric.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">The space between Hello and World is not alphanumeric.</span> </pre></div> </td></tr> <tr> <th><code>\s</code> </th> <td>Matches a whitespace character, <br />which in ASCII are tab, line feed, form feed, carriage return, and space; <br />in Unicode, also matches no-<wbr />break spaces, next line, and the variable-<wbr />width spaces (among others). </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/\s.*\s/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;In $string1 there are TWO whitespace characters, which may&quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot; be separated by other characters.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">In Hello World</span> <span class="go"> there are TWO whitespace characters, which may be separated by other characters.</span> </pre></div> </td></tr> <tr> <th><code>\S</code> </th> <td>Matches anything <i>but</i> a whitespace. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/\S.*\S/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;In $string1 there are TWO non-whitespace characters, which&quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot; may be separated by other characters.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">In Hello World</span> <span class="go"> there are TWO non-whitespace characters, which may be separated by other characters.</span> </pre></div> </td></tr> <tr> <th><code>\d</code> </th> <td>Matches a digit; <br />same as <code>[0-9]</code> in ASCII; <br />in Unicode, same as the <code>\p{Digit}</code> or <code>\p{GC=Decimal_Number}</code> property, which itself the same as the <code>\p{Numeric_Type=Decimal}</code> property. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;99 bottles of beer on the wall.&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/(\d+)/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$1 is the first number in &#39;$string1&#39;\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">99 is the first number in &#39;99 bottles of beer on the wall.&#39;</span> </pre></div> </td></tr> <tr> <th><code>\D</code> </th> <td>Matches a non-digit; <br />same as <code>[^0-9]</code> in ASCII or <code>\P{Digit}</code> in Unicode. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/\D/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;At least one character in $string1&quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot; is not a digit.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">At least one character in Hello World</span> <span class="go"> is not a digit.</span> </pre></div> </td></tr> <tr> <th><code>^</code> </th> <td>Matches the beginning of a line or string. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/^He/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 starts with the characters &#39;He&#39;.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello World</span> <span class="go"> starts with the characters &#39;He&#39;.</span> </pre></div> </td></tr> <tr> <th><code>$</code> </th> <td>Matches the end of a line or string. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/rld$/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 is a line or string &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;that ends with &#39;rld&#39;.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello World</span> <span class="go"> is a line or string that ends with &#39;rld&#39;.</span> </pre></div> </td></tr> <tr> <th><code>\A</code> </th> <td>Matches the beginning of a string (but not an internal line). </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello\nWorld\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/\AH/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 is a string &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;that starts with &#39;H&#39;.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello</span> <span class="go">World</span> <span class="go"> is a string that starts with &#39;H&#39;.</span> </pre></div> </td></tr> <tr> <th><code>\z</code> </th> <td>Matches the end of a string (but not an internal line).<sup id="cite_ref-Perl_Best_Practices_63-0" class="reference"><a href="#cite_note-Perl_Best_Practices-63"><span class="cite-bracket">&#91;</span>63<span class="cite-bracket">&#93;</span></a></sup> </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello\nWorld\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/d\n\z/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 is a string &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;that ends with &#39;d\\n&#39;.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello</span> <span class="go">World</span> <span class="go"> is a string that ends with &#39;d\n&#39;.</span> </pre></div> </td></tr> <tr> <th><code>[^…]</code> </th> <td>Matches every character except the ones inside brackets. </td> <td><div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$string1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Hello World\n&quot;</span><span class="p">;</span> <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$string1</span><span class="w"> </span><span class="o">=~</span><span class="w"> </span><span class="sr">m/[^abc]/</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;$string1 contains a character other than &quot;</span><span class="p">;</span> <span class="w"> </span><span class="k">print</span><span class="w"> </span><span class="s">&quot;a, b, and c.\n&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p><b>Output:</b> </p> <div class="mw-highlight mw-highlight-lang-output mw-content-ltr" dir="ltr"><pre><span></span><span class="go">Hello World</span> <span class="go"> contains a character other than a, b, and c.</span> </pre></div> </td></tr></tbody></table> <div class="mw-heading mw-heading2"><h2 id="Induction">Induction</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=25" title="Edit section: Induction"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951"><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Induction_of_regular_languages" title="Induction of regular languages">Induction of regular languages</a></div> <p>Regular expressions can often be created ("induced" or "learned") based on a set of example strings. This is known as the <a href="/wiki/Induction_of_regular_languages" title="Induction of regular languages">induction of regular languages</a> and is part of the general problem of <a href="/wiki/Grammar_induction" title="Grammar induction">grammar induction</a> in <a href="/wiki/Computational_learning_theory" title="Computational learning theory">computational learning theory</a>. Formally, given examples of strings in a regular language, and perhaps also given examples of strings <i>not</i> in that regular language, it is possible to induce a grammar for the language, i.e., a regular expression that generates that language. Not all regular languages can be induced in this way (see <a href="/wiki/Language_identification_in_the_limit" title="Language identification in the limit">language identification in the limit</a>), but many can. For example, the set of examples {1, 10, 100}, and negative set (of counterexamples) {11, 1001, 101, 0} can be used to induce the regular expression 1⋅0* (1 followed by zero or more 0s). </p> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=26" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a href="/wiki/Comparison_of_regular_expression_engines" title="Comparison of regular expression engines">Comparison of regular expression engines</a></li> <li><a href="/wiki/Extended_Backus%E2%80%93Naur_form" title="Extended Backus–Naur form">Extended Backus–Naur form</a></li> <li><a href="/wiki/Matching_wildcards" title="Matching wildcards">Matching wildcards</a></li> <li><a href="/wiki/Regular_tree_grammar" title="Regular tree grammar">Regular tree grammar</a></li> <li><a href="/wiki/Thompson%27s_construction" title="Thompson&#39;s construction">Thompson's construction</a> – converts a regular expression into an equivalent <a href="/wiki/Nondeterministic_finite_automaton" title="Nondeterministic finite automaton">nondeterministic finite automaton (NFA)</a></li></ul> <div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=27" title="Edit section: Notes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist"> <div class="mw-references-wrap mw-references-columns"><ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite id="CITEREFGoyvaerts" class="citation web cs1">Goyvaerts, Jan. <a rel="nofollow" class="external text" href="https://www.regular-expressions.info/tutorial.html">"Regular Expression Tutorial - Learn How to Use Regular Expressions"</a>. <i>Regular-Expressions.info</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20161101212501/http://www.regular-expressions.info/tutorial.html">Archived</a> from the original on 2016-11-01<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-10-31</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Regular-Expressions.info&amp;rft.atitle=Regular+Expression+Tutorial+-+Learn+How+to+Use+Regular+Expressions&amp;rft.aulast=Goyvaerts&amp;rft.aufirst=Jan&amp;rft_id=https%3A%2F%2Fwww.regular-expressions.info%2Ftutorial.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-Mitkov2003-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-Mitkov2003_2-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFMitkov2003" class="citation book cs1">Mitkov, Ruslan (2003). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=yl6AnaKtVAkC&amp;pg=PA754"><i>The Oxford Handbook of Computational Linguistics</i></a>. Oxford University Press. p.&#160;754. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-19-927634-9" title="Special:BookSources/978-0-19-927634-9"><bdi>978-0-19-927634-9</bdi></a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170228030346/https://books.google.com/books?id=yl6AnaKtVAkC&amp;pg=PA754">Archived</a> from the original on 2017-02-28<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-07-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=The+Oxford+Handbook+of+Computational+Linguistics&amp;rft.pages=754&amp;rft.pub=Oxford+University+Press&amp;rft.date=2003&amp;rft.isbn=978-0-19-927634-9&amp;rft.aulast=Mitkov&amp;rft.aufirst=Ruslan&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Dyl6AnaKtVAkC%26pg%3DPA754&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-Lawson2003-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-Lawson2003_3-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFLawson2003" class="citation book cs1">Lawson, Mark V. (17 September 2003). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=MDQ_K7-z2AMC&amp;pg=PA98"><i>Finite Automata</i></a>. CRC Press. pp.&#160;98–100. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-1-58488-255-8" title="Special:BookSources/978-1-58488-255-8"><bdi>978-1-58488-255-8</bdi></a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170227195128/https://books.google.com/books?id=MDQ_K7-z2AMC&amp;pg=PA98">Archived</a> from the original on 27 February 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">25 July</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Finite+Automata&amp;rft.pages=98-100&amp;rft.pub=CRC+Press&amp;rft.date=2003-09-17&amp;rft.isbn=978-1-58488-255-8&amp;rft.aulast=Lawson&amp;rft.aufirst=Mark+V.&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DMDQ_K7-z2AMC%26pg%3DPA98&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.regular-expressions.info/engine.html">"How a Regex Engine Works Internally"</a>. <i>regular-expressions.info</i><span class="reference-accessdate">. Retrieved <span class="nowrap">24 February</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=regular-expressions.info&amp;rft.atitle=How+a+Regex+Engine+Works+Internally&amp;rft_id=https%3A%2F%2Fwww.regular-expressions.info%2Fengine.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHeddings2020" class="citation web cs1">Heddings, Anthony (11 March 2020). <a rel="nofollow" class="external text" href="https://www.howtogeek.com/devops/how-do-you-actually-use-regex/">"How Do You Actually Use Regex?"</a>. <i>howtogeek.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">24 February</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=howtogeek.com&amp;rft.atitle=How+Do+You+Actually+Use+Regex%3F&amp;rft.date=2020-03-11&amp;rft.aulast=Heddings&amp;rft.aufirst=Anthony&amp;rft_id=https%3A%2F%2Fwww.howtogeek.com%2Fdevops%2Fhow-do-you-actually-use-regex%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-FOOTNOTEKleene1951-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEKleene1951_6-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFKleene1951">Kleene 1951</a>.</span> </li> <li id="cite_note-Leung,_New_Mexico_State_University,_2010-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-Leung,_New_Mexico_State_University,_2010_7-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFLeung2010" class="citation web cs1">Leung, Hing (16 September 2010). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20131205193130/https://www.cs.nmsu.edu/historical-projects/Projects/kleene.9.16.10.pdf">"Regular Languages and Finite Automata"</a> <span class="cs1-format">(PDF)</span>. <i><a href="/wiki/New_Mexico_State_University" title="New Mexico State University">New Mexico State University</a></i>. Archived from <a rel="nofollow" class="external text" href="https://www.cs.nmsu.edu/historical-projects/Projects/kleene.9.16.10.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 5 December 2013<span class="reference-accessdate">. Retrieved <span class="nowrap">13 August</span> 2019</span>. <q>The concept of regular events was introduced by Kleene via the definition of regular expressions.</q></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=New+Mexico+State+University&amp;rft.atitle=Regular+Languages+and+Finite+Automata&amp;rft.date=2010-09-16&amp;rft.aulast=Leung&amp;rft.aufirst=Hing&amp;rft_id=https%3A%2F%2Fwww.cs.nmsu.edu%2Fhistorical-projects%2FProjects%2Fkleene.9.16.10.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">Kleene 1951, <a rel="nofollow" class="external text" href="https://www.rand.org/content/dam/rand/pubs/research_memoranda/2008/RM704.pdf#page=49">pg46</a></span> </li> <li id="cite_note-FOOTNOTEThompson1968-9"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEThompson1968_9-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEThompson1968_9-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFThompson1968">Thompson 1968</a>.</span> </li> <li id="cite_note-FOOTNOTEJohnsonPorterAckleyRoss1968-10"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEJohnsonPorterAckleyRoss1968_10-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEJohnsonPorterAckleyRoss1968_10-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFJohnsonPorterAckleyRoss1968">Johnson et al. 1968</a>.</span> </li> <li id="cite_note-Beautiful_Code_Kernighan-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-Beautiful_Code_Kernighan_11-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFKernighan2007" class="citation book cs1"><a href="/wiki/Brian_Kernighan" title="Brian Kernighan">Kernighan, Brian</a> (2007-08-08). <a rel="nofollow" class="external text" href="http://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html">"A Regular Expressions Matcher"</a>. <i>Beautiful Code</i>. <a href="/wiki/O%27Reilly_Media" title="O&#39;Reilly Media">O'Reilly Media</a>. pp.&#160;1–2. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-596-51004-6" title="Special:BookSources/978-0-596-51004-6"><bdi>978-0-596-51004-6</bdi></a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183137/https://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-05-15</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=A+Regular+Expressions+Matcher&amp;rft.btitle=Beautiful+Code&amp;rft.pages=1-2&amp;rft.pub=O%27Reilly+Media&amp;rft.date=2007-08-08&amp;rft.isbn=978-0-596-51004-6&amp;rft.aulast=Kernighan&amp;rft.aufirst=Brian&amp;rft_id=http%3A%2F%2Fwww.cs.princeton.edu%2Fcourses%2Farchive%2Fspr09%2Fcos333%2Fbeautiful.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFRitchie" class="citation web cs1">Ritchie, Dennis M. <a rel="nofollow" class="external text" href="https://web.archive.org/web/19990221023422/http://cm.bell-labs.com/who/dmr/qed.html">"An incomplete history of the QED Text Editor"</a>. Archived from <a rel="nofollow" class="external text" href="http://cm.bell-labs.com/who/dmr/qed.html">the original</a> on 1999-02-21<span class="reference-accessdate">. Retrieved <span class="nowrap">9 October</span> 2013</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=An+incomplete+history+of+the+QED+Text+Editor&amp;rft.aulast=Ritchie&amp;rft.aufirst=Dennis+M.&amp;rft_id=http%3A%2F%2Fcm.bell-labs.com%2Fwho%2Fdmr%2Fqed.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-FOOTNOTEAhoUllman199210.11_Bibliographic_Notes_for_Chapter_10,_p._589-13"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEAhoUllman199210.11_Bibliographic_Notes_for_Chapter_10,_p._589_13-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEAhoUllman199210.11_Bibliographic_Notes_for_Chapter_10,_p._589_13-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFAhoUllman1992">Aho &amp; Ullman 1992</a>, 10.11 Bibliographic Notes for Chapter 10, p. 589.</span> </li> <li id="cite_note-FOOTNOTEAycock200398-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEAycock200398_14-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFAycock2003">Aycock 2003</a>, p.&#160;98.</span> </li> <li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFRaymond,_Eric_S._citing_Dennis_Ritchie2003" class="citation web cs1"><a href="/wiki/Eric_S._Raymond" title="Eric S. Raymond">Raymond, Eric S.</a> citing <a href="/wiki/Dennis_Ritchie" title="Dennis Ritchie">Dennis Ritchie</a> (2003). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110605165512/http://www.catb.org/jargon/html/G/grep.html">"Jargon File 4.4.7: grep"</a>. Archived from <a rel="nofollow" class="external text" href="http://catb.org/jargon/html/G/grep.html">the original</a> on 2011-06-05<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-02-17</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Jargon+File+4.4.7%3A+grep&amp;rft.date=2003&amp;rft.au=Raymond%2C+Eric+S.+citing+Dennis+Ritchie&amp;rft_id=http%3A%2F%2Fcatb.org%2Fjargon%2Fhtml%2FG%2Fgrep.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.tcl.tk/doc/howto/regexp81.html">"New Regular Expression Features in Tcl 8.1"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183137/http://www.tcl.tk/doc/howto/regexp81.html">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-10-11</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=New+Regular+Expression+Features+in+Tcl+8.1&amp;rft_id=http%3A%2F%2Fwww.tcl.tk%2Fdoc%2Fhowto%2Fregexp81.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.postgresql.org/docs/9.3/interactive/functions-matching.html">"Documentation: 9.3: Pattern Matching"</a>. <i>PostgreSQL</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183140/https://www.postgresql.org/docs/9.3/functions-matching.html">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-10-12</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=PostgreSQL&amp;rft.atitle=Documentation%3A+9.3%3A+Pattern+Matching&amp;rft_id=http%3A%2F%2Fwww.postgresql.org%2Fdocs%2F9.3%2Finteractive%2Ffunctions-matching.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFWall,_Larry2006" class="citation web cs1"><a href="/wiki/Larry_Wall" title="Larry Wall">Wall, Larry</a> (2006). <a rel="nofollow" class="external text" href="http://perldoc.perl.org/perlre.html">"Perl Regular Expressions"</a>. <i>perlre</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20091231010052/http://perldoc.perl.org/perlre.html">Archived</a> from the original on 2009-12-31<span class="reference-accessdate">. Retrieved <span class="nowrap">2006-10-10</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=perlre&amp;rft.atitle=Perl+Regular+Expressions&amp;rft.date=2006&amp;rft.au=Wall%2C+Larry&amp;rft_id=http%3A%2F%2Fperldoc.perl.org%2Fperlre.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-Apocalypse5-19"><span class="mw-cite-backlink">^ <a href="#cite_ref-Apocalypse5_19-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Apocalypse5_19-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFWall2002">Wall (2002)</a></span> </li> <li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.pcre.org/">"PCRE - Perl Compatible Regular Expressions"</a>. <i>www.pcre.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2024-04-07</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=www.pcre.org&amp;rft.atitle=PCRE+-+Perl+Compatible+Regular+Expressions&amp;rft_id=https%3A%2F%2Fwww.pcre.org%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://grovf.com/products/gregex">"GRegex – Faster Analytics for Unstructured Text Data"</a>. <i>grovf.com</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183139/https://grovf.com/products/gregex">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2019-10-22</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=grovf.com&amp;rft.atitle=GRegex+%E2%80%93+Faster+Analytics+for+Unstructured+Text+Data&amp;rft_id=https%3A%2F%2Fgrovf.com%2Fproducts%2Fgregex&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://bkase.github.io/CUDA-grep/finalreport.html">"CUDA grep"</a>. <i>bkase.github.io</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183138/http://bkase.github.io/CUDA-grep/finalreport.html">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2019-10-22</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=bkase.github.io&amp;rft.atitle=CUDA+grep&amp;rft_id=http%3A%2F%2Fbkase.github.io%2FCUDA-grep%2Ffinalreport.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-grep-23"><span class="mw-cite-backlink">^ <a href="#cite_ref-grep_23-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-grep_23-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-grep_23-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-grep_23-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFKerrisk" class="citation web cs1">Kerrisk, Michael. <a rel="nofollow" class="external text" href="https://man7.org/linux/man-pages/man1/grep.1.html">"grep(1) - Linux manual page"</a>. <i>man7.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">31 January</span> 2023</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=man7.org&amp;rft.atitle=grep%281%29+-+Linux+manual+page&amp;rft.aulast=Kerrisk&amp;rft.aufirst=Michael&amp;rft_id=https%3A%2F%2Fman7.org%2Flinux%2Fman-pages%2Fman1%2Fgrep.1.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-HopcroftMotwaniUllman01-24"><span class="mw-cite-backlink">^ <a href="#cite_ref-HopcroftMotwaniUllman01_24-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-HopcroftMotwaniUllman01_24-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFHopcroftMotwaniUllman2000">Hopcroft, Motwani &amp; Ullman (2000)</a></span> </li> <li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><a href="#CITEREFSipser1998">Sipser (1998)</a></span> </li> <li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text"><a href="#CITEREFGeladeNeven2008">Gelade &amp; Neven (2008</a>, p.&#160;332, Thm.4.1)</span> </li> <li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><a href="#CITEREFGruberHolzer2008">Gruber &amp; Holzer (2008)</a></span> </li> <li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text">Based on <a href="#CITEREFGeladeNeven2008">Gelade &amp; Neven (2008)</a>, a regular expression of length about 850 such that its complement has a length about 2<sup>32</sup> can be found at <a href="/wiki/File:RegexComplementBlowup.png" title="File:RegexComplementBlowup.png">File:RegexComplementBlowup.png</a>.</span> </li> <li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://s3.boskent.com/divisibility-regex/divisibility-regex.html">"Regular expressions for deciding divisibility"</a>. <i>s3.boskent.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2024-02-21</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=s3.boskent.com&amp;rft.atitle=Regular+expressions+for+deciding+divisibility&amp;rft_id=https%3A%2F%2Fs3.boskent.com%2Fdivisibility-regex%2Fdivisibility-regex.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-30">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFGischer1984" class="citation report cs1">Gischer, Jay L. (1984). (Title unknown) (Technical Report). Stanford Univ., Dept. of Comp. Sc.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=report&amp;rft.btitle=%28Title+unknown%29&amp;rft.pub=Stanford+Univ.%2C+Dept.+of+Comp.+Sc.&amp;rft.date=1984&amp;rft.aulast=Gischer&amp;rft.aufirst=Jay+L.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span><sup class="noprint Inline-Template" style="white-space:nowrap;">&#91;<i><a href="/wiki/Wikipedia:Citing_sources" title="Wikipedia:Citing sources"><span title="Please supply either &quot;&#124;first=&quot; and the actual title of the cited work, or use &quot;&#124;title=&#91;untitled&#93;&quot; for intentional omission. (February 2023)">title&#160;missing</span></a></i>&#93;</sup></span> </li> <li id="cite_note-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-31">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHopcroftMotwaniUllman2003" class="citation book cs1">Hopcroft, John E.; Motwani, Rajeev &amp; Ullman, Jeffrey D. (2003). <i>Introduction to Automata Theory, Languages, and Computation</i>. Upper Saddle River, New Jersey: Addison Wesley. pp.&#160;117–120. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-201-44124-6" title="Special:BookSources/978-0-201-44124-6"><bdi>978-0-201-44124-6</bdi></a>. <q>This property need not hold for extended regular expressions, even if they describe no larger class than regular languages; cf. p.121.</q></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Introduction+to+Automata+Theory%2C+Languages%2C+and+Computation&amp;rft.place=Upper+Saddle+River%2C+New+Jersey&amp;rft.pages=117-120&amp;rft.pub=Addison+Wesley&amp;rft.date=2003&amp;rft.isbn=978-0-201-44124-6&amp;rft.aulast=Hopcroft&amp;rft.aufirst=John+E.&amp;rft.au=Motwani%2C+Rajeev&amp;rft.au=Ullman%2C+Jeffrey+D.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-32">^</a></b></span> <span class="reference-text"><a href="#CITEREFKozen1991">Kozen (1991)</a><sup class="noprint Inline-Template" style="white-space:nowrap;">&#91;<i><a href="/wiki/Wikipedia:Citing_sources" title="Wikipedia:Citing sources"><span title="This citation requires a reference to the specific page or range of pages in which the material appears. (February 2015)">page&#160;needed</span></a></i>&#93;</sup></span> </li> <li id="cite_note-33"><span class="mw-cite-backlink"><b><a href="#cite_ref-33">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFRedko1964" class="citation journal cs1 cs1-prop-foreign-lang-source">Redko, V.N. (1964). <a rel="nofollow" class="external text" href="http://umj.imath.kiev.ua/article/?article=10002">"On defining relations for the algebra of regular events"</a>. <i>Ukrainskii Matematicheskii Zhurnal</i> (in Russian). <b>16</b> (1): 120–126. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20180329121016/http://umj.imath.kiev.ua/article/?article=10002">Archived</a> from the original on 2018-03-29<span class="reference-accessdate">. Retrieved <span class="nowrap">2018-03-28</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Ukrainskii+Matematicheskii+Zhurnal&amp;rft.atitle=On+defining+relations+for+the+algebra+of+regular+events&amp;rft.volume=16&amp;rft.issue=1&amp;rft.pages=120-126&amp;rft.date=1964&amp;rft.aulast=Redko&amp;rft.aufirst=V.N.&amp;rft_id=http%3A%2F%2Fumj.imath.kiev.ua%2Farticle%2F%3Farticle%3D10002&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-34"><span class="mw-cite-backlink"><b><a href="#cite_ref-34">^</a></b></span> <span class="reference-text">ISO/IEC 9945-2:1993 <i>Information technology – Portable Operating System Interface (POSIX) – Part 2: Shell and Utilities</i>, successively revised as ISO/IEC 9945-2:2002 <i>Information technology – Portable Operating System Interface (POSIX) – Part 2: System Interfaces</i>, ISO/IEC 9945-2:2003, and currently ISO/IEC/IEEE 9945:2009 <i>Information technology – Portable Operating System Interface (POSIX) Base Specifications, Issue 7</i></span> </li> <li id="cite_note-35"><span class="mw-cite-backlink"><b><a href="#cite_ref-35">^</a></b></span> <span class="reference-text">The Single Unix Specification (Version 2)</span> </li> <li id="cite_note-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-36">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1"><a rel="nofollow" class="external text" href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_06">"9.3.6 BREs Matching Multiple Characters"</a>. <i>The Open Group Base Specifications Issue 7, 2018 edition</i>. The Open Group. 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">December 10,</span> 2023</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=9.3.6+BREs+Matching+Multiple+Characters&amp;rft.btitle=The+Open+Group+Base+Specifications+Issue+7%2C+2018+edition&amp;rft.pub=The+Open+Group&amp;rft.date=2017&amp;rft_id=https%3A%2F%2Fpubs.opengroup.org%2Fonlinepubs%2F9699919799%2Fbasedefs%2FV1_chap09.html%23tag_09_03_06&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-37"><span class="mw-cite-backlink"><b><a href="#cite_ref-37">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFRuss_Cox2009" class="citation web cs1">Russ Cox (2009). <a rel="nofollow" class="external text" href="https://swtch.com/~rsc/regexp/regexp2.html">"Regular Expression Matching: the Virtual Machine Approach"</a>. <i>swtch.com</i>. <q>Digression: POSIX Submatching</q></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=swtch.com&amp;rft.atitle=Regular+Expression+Matching%3A+the+Virtual+Machine+Approach&amp;rft.date=2009&amp;rft.au=Russ+Cox&amp;rft_id=https%3A%2F%2Fswtch.com%2F~rsc%2Fregexp%2Fregexp2.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-38"><span class="mw-cite-backlink"><b><a href="#cite_ref-38">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://perldoc.perl.org/perlre#PCRE%2fPython-Support">"Perl Regular Expression Documentation"</a>. perldoc.perl.org. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20091231010052/http://perldoc.perl.org/perlre.html#PCRE%2fPython-Support">Archived</a> from the original on December 31, 2009<span class="reference-accessdate">. Retrieved <span class="nowrap">November 5,</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Perl+Regular+Expression+Documentation&amp;rft.pub=perldoc.perl.org&amp;rft_id=https%3A%2F%2Fperldoc.perl.org%2Fperlre%23PCRE%252fPython-Support&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-py-re-39"><span class="mw-cite-backlink">^ <a href="#cite_ref-py-re_39-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-py-re_39-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20180718132241/https://docs.python.org/3/library/re.html#regular-expression-syntax">"Regular Expression Syntax"</a>. <i>Python 3.5.0 documentation</i>. <a href="/wiki/Python_Software_Foundation" title="Python Software Foundation">Python Software Foundation</a>. Archived from <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/re.html#regular-expression-syntax">the original</a> on 18 July 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">10 October</span> 2015</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Python+3.5.0+documentation&amp;rft.atitle=Regular+Expression+Syntax&amp;rft_id=https%3A%2F%2Fdocs.python.org%2F3%2Flibrary%2Fre.html%23regular-expression-syntax&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-40"><span class="mw-cite-backlink"><b><a href="#cite_ref-40">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://github.com/python/cpython/issues/34627/">SRE: Atomic Grouping (?&gt;...) is not supported #34627</a></span> </li> <li id="cite_note-es-re-41"><span class="mw-cite-backlink">^ <a href="#cite_ref-es-re_41-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-es-re_41-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.oracle.com/javase/tutorial/essential/regex/quant.html#difs">"Essential classes: Regular Expressions: Quantifiers: Differences Among Greedy, Reluctant, and Possessive Quantifiers"</a>. <i>The Java Tutorials</i>. <a href="/wiki/Oracle_Corporation" title="Oracle Corporation">Oracle</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183203/https://docs.oracle.com/javase/tutorial/essential/regex/quant.html#difs">Archived</a> from the original on 7 October 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">23 December</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=The+Java+Tutorials&amp;rft.atitle=Essential+classes%3A+Regular+Expressions%3A+Quantifiers%3A+Differences+Among+Greedy%2C+Reluctant%2C+and+Possessive+Quantifiers&amp;rft_id=https%3A%2F%2Fdocs.oracle.com%2Fjavase%2Ftutorial%2Fessential%2Fregex%2Fquant.html%23difs&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-42"><span class="mw-cite-backlink"><b><a href="#cite_ref-42">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.regular-expressions.info/atomic.html">"Atomic Grouping"</a>. <i>Regex Tutorial</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183204/https://www.regular-expressions.info/atomic.html">Archived</a> from the original on 7 October 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">24 November</span> 2019</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Regex+Tutorial&amp;rft.atitle=Atomic+Grouping&amp;rft_id=https%3A%2F%2Fwww.regular-expressions.info%2Fatomic.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-43"><span class="mw-cite-backlink"><b><a href="#cite_ref-43">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFBormannBray" class="citation cs1">Bormann, Carsten; Bray, Tim. <a rel="nofollow" class="external text" href="https://datatracker.ietf.org/doc/html/rfc9485"><i>I-Regexp: An Interoperable Regular Expression Format</i></a>. Internet Engineering Task Force. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.17487%2FRFC9485">10.17487/RFC9485</a></span>. <a href="/wiki/Request_for_Comments" title="Request for Comments">RFC</a> <a rel="nofollow" class="external text" href="https://datatracker.ietf.org/doc/html/rfc9485">9485</a><span class="reference-accessdate">. Retrieved <span class="nowrap">11 March</span> 2024</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=I-Regexp%3A+An+Interoperable+Regular+Expression+Format&amp;rft.pub=Internet+Engineering+Task+Force&amp;rft_id=info%3Adoi%2F10.17487%2F&#82;FC9485&amp;rft.aulast=Bormann&amp;rft.aufirst=Carsten&amp;rft.au=Bray%2C+Tim&amp;rft_id=https%3A%2F%2Fdatatracker.ietf.org%2Fdoc%2Fhtml%2Frfc9485&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-44"><span class="mw-cite-backlink"><b><a href="#cite_ref-44">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFCezar_CâmpeanuKai_SalomaaSheng_Yu2003" class="citation journal cs1">Cezar Câmpeanu; Kai Salomaa &amp; Sheng Yu (Dec 2003). <a rel="nofollow" class="external text" href="http://137.149.157.5/Articles/index.php?aid=1">"A Formal Study of Practical Regular Expressions"</a>. <i>International Journal of Foundations of Computer Science</i>. <b>14</b> (6): 1007–1018. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1142%2FS012905410300214X">10.1142/S012905410300214X</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20150704141706/http://137.149.157.5/Articles/index.php?aid=1">Archived</a> from the original on 2015-07-04<span class="reference-accessdate">. Retrieved <span class="nowrap">2015-07-03</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=International+Journal+of+Foundations+of+Computer+Science&amp;rft.atitle=A+Formal+Study+of+Practical+Regular+Expressions&amp;rft.volume=14&amp;rft.issue=6&amp;rft.pages=1007-1018&amp;rft.date=2003-12&amp;rft_id=info%3Adoi%2F10.1142%2FS012905410300214X&amp;rft.au=Cezar+C%C3%A2mpeanu&amp;rft.au=Kai+Salomaa&amp;rft.au=Sheng+Yu&amp;rft_id=http%3A%2F%2F137.149.157.5%2FArticles%2Findex.php%3Faid%3D1&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span> Theorem 3 (p.9)</span> </li> <li id="cite_note-45"><span class="mw-cite-backlink"><b><a href="#cite_ref-45">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://perl.plover.com/NPC/">"Perl Regular Expression Matching is NP-Hard"</a>. <i>perl.plover.com</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183205/https://perl.plover.com/NPC/">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2019-11-21</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=perl.plover.com&amp;rft.atitle=Perl+Regular+Expression+Matching+is+NP-Hard&amp;rft_id=https%3A%2F%2Fperl.plover.com%2FNPC%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-46"><span class="mw-cite-backlink"><b><a href="#cite_ref-46">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFRitchieThompson1970" class="citation book cs1">Ritchie, D. M.; Thompson, K. L. (June 1970). <a rel="nofollow" class="external text" href="https://wayback.archive-it.org/all/20150203071645/http://cm.bell-labs.com/cm/cs/who/dmr/qedman.pdf"><i>QED Text Editor</i></a> <span class="cs1-format">(PDF)</span>. MM-70-1373-3. Archived from <a rel="nofollow" class="external text" href="http://cm.bell-labs.com/cm/cs/who/dmr/qedman.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2015-02-03<span class="reference-accessdate">. Retrieved <span class="nowrap">2022-09-05</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=QED+Text+Editor&amp;rft.date=1970-06&amp;rft.aulast=Ritchie&amp;rft.aufirst=D.+M.&amp;rft.au=Thompson%2C+K.+L.&amp;rft_id=http%3A%2F%2Fcm.bell-labs.com%2Fcm%2Fcs%2Fwho%2Fdmr%2Fqedman.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span> Reprinted as "QED Text Editor Reference Manual", MHCC-004, Murray Hill Computing, Bell Laboratories (October 1972).</span> </li> <li id="cite_note-perl5-47"><span class="mw-cite-backlink">^ <a href="#cite_ref-perl5_47-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-perl5_47-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFWall1994" class="citation web cs1">Wall, Larry (1994-10-18). <a rel="nofollow" class="external text" href="https://github.com/Perl/perl5/blob/a0d0e21ea6ea90a22318550944fe6cb09ae10cda/pod/perlre.pod">"Perl 5: perlre.pod"</a>. <i>GitHub</i>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=GitHub&amp;rft.atitle=Perl+5%3A+perlre.pod&amp;rft.date=1994-10-18&amp;rft.aulast=Wall&amp;rft.aufirst=Larry&amp;rft_id=https%3A%2F%2Fgithub.com%2FPerl%2Fperl5%2Fblob%2Fa0d0e21ea6ea90a22318550944fe6cb09ae10cda%2Fpod%2Fperlre.pod&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-48"><span class="mw-cite-backlink"><b><a href="#cite_ref-48">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFWandering_Logic" class="citation web cs1">Wandering Logic. <a rel="nofollow" class="external text" href="https://cs.stackexchange.com/a/40058">"How to simulate lookaheads and lookbehinds in finite state automata?"</a>. <i>Computer Science Stack Exchange</i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183206/https://cs.stackexchange.com/questions/2557/how-to-simulate-backreferences-lookaheads-and-lookbehinds-in-finite-state-auto/40058">Archived</a> from the original on 7 October 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">24 November</span> 2019</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Computer+Science+Stack+Exchange&amp;rft.atitle=How+to+simulate+lookaheads+and+lookbehinds+in+finite+state+automata%3F&amp;rft.au=Wandering+Logic&amp;rft_id=https%3A%2F%2Fcs.stackexchange.com%2Fa%2F40058&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-49"><span class="mw-cite-backlink"><b><a href="#cite_ref-49">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFZakharevich1997" class="citation web cs1">Zakharevich, Ilya (1997-11-19). <a rel="nofollow" class="external text" href="https://github.com/Perl/perl5/commit/c277df42229d99fecbc76f5da53793a409ac66e1">"Jumbo Regexp Patch Applied (with Minor Fix-Up Tweaks): Perl/perl5@c277df4"</a>. <i>GitHub</i>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=GitHub&amp;rft.atitle=Jumbo+Regexp+Patch+Applied+%28with+Minor+Fix-Up+Tweaks%29%3A+Perl%2Fperl5%40c277df4&amp;rft.date=1997-11-19&amp;rft.aulast=Zakharevich&amp;rft.aufirst=Ilya&amp;rft_id=https%3A%2F%2Fgithub.com%2FPerl%2Fperl5%2Fcommit%2Fc277df42229d99fecbc76f5da53793a409ac66e1&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-50"><span class="mw-cite-backlink"><b><a href="#cite_ref-50">^</a></b></span> <span class="reference-text"><a href="#CITEREFCox2007">Cox (2007)</a></span> </li> <li id="cite_note-51"><span class="mw-cite-backlink"><b><a href="#cite_ref-51">^</a></b></span> <span class="reference-text"><a href="#CITEREFLaurikari2009">Laurikari (2009)</a></span> </li> <li id="cite_note-52"><span class="mw-cite-backlink"><b><a href="#cite_ref-52">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20210818191338/https://git.savannah.gnu.org/gitweb/?p=gnulib.git%3Ba%3Dblob%3Bf%3Dlib%2Fdfa.c">"gnulib/lib/dfa.c"</a>. Archived from <a rel="nofollow" class="external text" href="https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/dfa.c">the original</a> on 2021-08-18<span class="reference-accessdate">. Retrieved <span class="nowrap">2022-02-12</span></span>. <q>If the scanner detects a transition on backref, it returns a kind of "semi-success" indicating that the match will have to be verified with a backtracking matcher.</q></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=gnulib%2Flib%2Fdfa.c&amp;rft_id=https%3A%2F%2Fgit.savannah.gnu.org%2Fgitweb%2F%3Fp%3Dgnulib.git%3Ba%3Dblob%3Bf%3Dlib%2Fdfa.c&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-53"><span class="mw-cite-backlink"><b><a href="#cite_ref-53">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFKearns2013" class="citation arxiv cs1">Kearns, Steven (August 2013). "Sublinear Matching With Finite Automata Using Reverse Suffix Scanning". <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1308.3822">1308.3822</a></span> [<a rel="nofollow" class="external text" href="https://arxiv.org/archive/cs.DS">cs.DS</a>].</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=preprint&amp;rft.jtitle=arXiv&amp;rft.atitle=Sublinear+Matching+With+Finite+Automata+Using+Reverse+Suffix+Scanning&amp;rft.date=2013-08&amp;rft_id=info%3Aarxiv%2F1308.3822&amp;rft.aulast=Kearns&amp;rft.aufirst=Steven&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-54"><span class="mw-cite-backlink"><b><a href="#cite_ref-54">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFNavarro2001" class="citation journal cs1">Navarro, Gonzalo (10 November 2001). <a rel="nofollow" class="external text" href="https://users.dcc.uchile.cl/~gnavarro/ps/spe01.pdf">"NR-grep: a fast and flexible pattern-matching tool"</a> <span class="cs1-format">(PDF)</span>. <i>Software: Practice and Experience</i>. <b>31</b> (13): 1265–1312. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1002%2Fspe.411">10.1002/spe.411</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:3175806">3175806</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183210/https://users.dcc.uchile.cl/~gnavarro/ps/spe01.pdf">Archived</a> <span class="cs1-format">(PDF)</span> from the original on 7 October 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">21 November</span> 2019</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Software%3A+Practice+and+Experience&amp;rft.atitle=NR-grep%3A+a+fast+and+flexible+pattern-matching+tool&amp;rft.volume=31&amp;rft.issue=13&amp;rft.pages=1265-1312&amp;rft.date=2001-11-10&amp;rft_id=info%3Adoi%2F10.1002%2Fspe.411&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A3175806%23id-name%3DS2CID&amp;rft.aulast=Navarro&amp;rft.aufirst=Gonzalo&amp;rft_id=https%3A%2F%2Fusers.dcc.uchile.cl%2F~gnavarro%2Fps%2Fspe01.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-55"><span class="mw-cite-backlink"><b><a href="#cite_ref-55">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/travisdowns/polyregex">"travisdowns/polyregex"</a>. <i><a href="/wiki/GitHub" title="GitHub">GitHub</a></i>. 5 July 2019. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200914170309/https://github.com/travisdowns/polyregex">Archived</a> from the original on 14 September 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">21 November</span> 2019</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=GitHub&amp;rft.atitle=travisdowns%2Fpolyregex&amp;rft.date=2019-07-05&amp;rft_id=https%3A%2F%2Fgithub.com%2Ftravisdowns%2Fpolyregex&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-56"><span class="mw-cite-backlink"><b><a href="#cite_ref-56">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFSchmid2019" class="citation arxiv cs1">Schmid, Markus L. (March 2019). "Regular Expressions with Backreferences: Polynomial-Time Matching Techniques". <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1903.05896">1903.05896</a></span> [<a rel="nofollow" class="external text" href="https://arxiv.org/archive/cs.FL">cs.FL</a>].</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=preprint&amp;rft.jtitle=arXiv&amp;rft.atitle=Regular+Expressions+with+Backreferences%3A+Polynomial-Time+Matching+Techniques&amp;rft.date=2019-03&amp;rft_id=info%3Aarxiv%2F1903.05896&amp;rft.aulast=Schmid&amp;rft.aufirst=Markus+L.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-57"><span class="mw-cite-backlink"><b><a href="#cite_ref-57">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5B%5D">"Vim documentation: pattern"</a>. Vimdoc.sourceforge.net. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183210/http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5B%5D">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-09-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Vim+documentation%3A+pattern&amp;rft.pub=Vimdoc.sourceforge.net&amp;rft_id=http%3A%2F%2Fvimdoc.sourceforge.net%2Fhtmldoc%2Fpattern.html%23%2F%255B%255D&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-unicode-58"><span class="mw-cite-backlink">^ <a href="#cite_ref-unicode_58-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-unicode_58-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://unicode.org/reports/tr18/#Character_Blocks">"UTS#18 on Unicode Regular Expressions, Annex A: Character Blocks"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183210/http://unicode.org/reports/tr18/#Character_Blocks">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2010-02-05</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=UTS%2318+on+Unicode+Regular+Expressions%2C+Annex+A%3A+Character+Blocks&amp;rft_id=https%3A%2F%2Funicode.org%2Freports%2Ftr18%2F%23Character_Blocks&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-59"><span class="mw-cite-backlink"><b><a href="#cite_ref-59">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHorowitz2011" class="citation web cs1"><a href="/wiki/Bradley_Horowitz" title="Bradley Horowitz">Horowitz, Bradley</a> (24 October 2011). <a rel="nofollow" class="external text" href="https://googleblog.blogspot.com/2011/10/fall-sweep.html">"A fall sweep"</a>. <i><a href="/wiki/Google_Blog" class="mw-redirect" title="Google Blog">Google Blog</a></i>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20181021074737/https://googleblog.blogspot.com/2011/10/fall-sweep.html">Archived</a> from the original on 21 October 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">4 May</span> 2019</span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Google+Blog&amp;rft.atitle=A+fall+sweep&amp;rft.date=2011-10-24&amp;rft.aulast=Horowitz&amp;rft.aufirst=Bradley&amp;rft_id=https%3A%2F%2Fgoogleblog.blogspot.com%2F2011%2F10%2Ffall-sweep.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> <li id="cite_note-clarify000-60"><span class="mw-cite-backlink"><b><a href="#cite_ref-clarify000_60-0">^</a></b></span> <span class="reference-text">The character 'm' is not always required to specify a <a href="/wiki/Perl" title="Perl">Perl</a> match operation. For example, <code>m/[^abc]/</code> could also be rendered as <code>/[^abc]/</code>. The 'm' is only necessary if the user wishes to specify a match operation without using a forward-slash as the regex <a href="/wiki/Delimiter" title="Delimiter">delimiter</a>. Sometimes it is useful to specify an alternate regex delimiter in order to avoid "<a href="/wiki/Delimiter_collision" class="mw-redirect" title="Delimiter collision">delimiter collision</a>". See '<a rel="nofollow" class="external text" href="http://perldoc.perl.org/perlre.html">perldoc perlre</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20091231010052/http://perldoc.perl.org/perlre.html">Archived</a> 2009-12-31 at the <a href="/wiki/Wayback_Machine" title="Wayback Machine">Wayback Machine</a>' for more details.</span> </li> <li id="cite_note-61"><span class="mw-cite-backlink"><b><a href="#cite_ref-61">^</a></b></span> <span class="reference-text">E.g., see <i><a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> <a href="/wiki/O%27Reilly_Media#In_a_Nutshell" title="O&#39;Reilly Media">in a Nutshell</a></i>, p. 213; <i><a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a> Scripting for Computational Science</i>, p. 320; Programming <a href="/wiki/PHP" title="PHP">PHP</a>, p. 106.</span> </li> <li id="cite_note-62"><span class="mw-cite-backlink"><b><a href="#cite_ref-62">^</a></b></span> <span class="reference-text">All the if statements return a TRUE value</span> </li> <li id="cite_note-Perl_Best_Practices-63"><span class="mw-cite-backlink"><b><a href="#cite_ref-Perl_Best_Practices_63-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFConway2005" class="citation book cs1"><a href="/wiki/Damian_Conway" title="Damian Conway">Conway, Damian</a> (2005). <a rel="nofollow" class="external text" href="https://www.scribd.com/doc/15491004/Perl-Best-Practices">"Regular Expressions, End of String"</a>. <i>Perl Best Practices</i>. <a href="/wiki/O%27Reilly_Media" title="O&#39;Reilly Media">O'Reilly</a>. p.&#160;240. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-596-00173-5" title="Special:BookSources/978-0-596-00173-5"><bdi>978-0-596-00173-5</bdi></a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183212/https://www.scribd.com/book/15491004/Perl-Best-Practices-Standards-and-Styles-for-Developing-Maintainable-Code">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2017-09-10</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Regular+Expressions%2C+End+of+String&amp;rft.btitle=Perl+Best+Practices&amp;rft.pages=240&amp;rft.pub=O%27Reilly&amp;rft.date=2005&amp;rft.isbn=978-0-596-00173-5&amp;rft.aulast=Conway&amp;rft.aufirst=Damian&amp;rft_id=https%3A%2F%2Fwww.scribd.com%2Fdoc%2F15491004%2FPerl-Best-Practices&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="References">References</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=28" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239549316">.mw-parser-output .refbegin{margin-bottom:0.5em}.mw-parser-output .refbegin-hanging-indents>ul{margin-left:0}.mw-parser-output .refbegin-hanging-indents>ul>li{margin-left:0;padding-left:3.2em;text-indent:-3.2em}.mw-parser-output .refbegin-hanging-indents ul,.mw-parser-output .refbegin-hanging-indents ul li{list-style:none}@media(max-width:720px){.mw-parser-output .refbegin-hanging-indents>ul>li{padding-left:1.6em;text-indent:-1.6em}}.mw-parser-output .refbegin-columns{margin-top:0.3em}.mw-parser-output .refbegin-columns ul{margin-top:0}.mw-parser-output .refbegin-columns li{page-break-inside:avoid;break-inside:avoid-column}@media screen{.mw-parser-output .refbegin{font-size:90%}}</style><div class="refbegin refbegin-columns references-column-width" style="column-width: 30em"> <ul><li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFAho1990" class="citation book cs1"><a href="/wiki/Alfred_Aho" title="Alfred Aho">Aho, Alfred V.</a> (1990). "Algorithms for finding patterns in strings". In <a href="/wiki/Jan_van_Leeuwen" title="Jan van Leeuwen">van Leeuwen, Jan</a> (ed.). <i>Handbook of Theoretical Computer Science, volume A: Algorithms and Complexity</i>. The MIT Press. pp.&#160;255–300.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Algorithms+for+finding+patterns+in+strings&amp;rft.btitle=Handbook+of+Theoretical+Computer+Science%2C+volume+A%3A+Algorithms+and+Complexity&amp;rft.pages=255-300&amp;rft.pub=The+MIT+Press&amp;rft.date=1990&amp;rft.aulast=Aho&amp;rft.aufirst=Alfred+V.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFAhoUllman1992" class="citation book cs1">Aho, Alfred V.; <a href="/wiki/Jeffrey_Ullman" title="Jeffrey Ullman">Ullman, Jeffrey D.</a> (1992). <a rel="nofollow" class="external text" href="http://infolab.stanford.edu/~ullman/focs/ch10.pdf">"Chapter 10. Patterns, Automata, and Regular Expressions"</a> <span class="cs1-format">(PDF)</span>. <a rel="nofollow" class="external text" href="http://infolab.stanford.edu/~ullman/focs.html"><i>Foundations of Computer Science</i></a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183211/http://infolab.stanford.edu/~ullman/focs.html">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-12-14</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Chapter+10.+Patterns%2C+Automata%2C+and+Regular+Expressions&amp;rft.btitle=Foundations+of+Computer+Science&amp;rft.date=1992&amp;rft.aulast=Aho&amp;rft.aufirst=Alfred+V.&amp;rft.au=Ullman%2C+Jeffrey+D.&amp;rft_id=http%3A%2F%2Finfolab.stanford.edu%2F~ullman%2Ffocs%2Fch10.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFAycock2003" class="citation journal cs1">Aycock, John (June 2003). <a rel="nofollow" class="external text" href="https://www.cs.tufts.edu/comp/150CMP/papers/aycock03jit.pdf">"A brief history of just-in-time"</a> <span class="cs1-format">(PDF)</span>. <i>ACM Computing Surveys</i>. <b>35</b> (2): 97–113. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.97.3985">10.1.1.97.3985</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F857076.857077">10.1145/857076.857077</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:15345671">15345671</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=ACM+Computing+Surveys&amp;rft.atitle=A+brief+history+of+just-in-time&amp;rft.volume=35&amp;rft.issue=2&amp;rft.pages=97-113&amp;rft.date=2003-06&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.97.3985%23id-name%3DCiteSeerX&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A15345671%23id-name%3DS2CID&amp;rft_id=info%3Adoi%2F10.1145%2F857076.857077&amp;rft.aulast=Aycock&amp;rft.aufirst=John&amp;rft_id=https%3A%2F%2Fwww.cs.tufts.edu%2Fcomp%2F150CMP%2Fpapers%2Faycock03jit.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1">"Regular Expressions". <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/007908799/xbd/re.html"><i>The Single UNIX Specification, Version 2</i></a>. The Open Group. 1997. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183212/https://pubs.opengroup.org/onlinepubs/007908799/xbd/re.html">Archived</a> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-12-13</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Regular+Expressions&amp;rft.btitle=The+Single+UNIX+Specification%2C+Version+2&amp;rft.pub=The+Open+Group&amp;rft.date=1997&amp;rft_id=http%3A%2F%2Fpubs.opengroup.org%2Fonlinepubs%2F007908799%2Fxbd%2Fre.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation journal cs1"><a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html">"Chapter 9: Regular Expressions"</a>. <i>The Open Group Base Specifications</i> (6). The Open Group. 2004. IEEE Std 1003.1, 2004 Edition. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20111202145637/http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html">Archived</a> from the original on 2011-12-02<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-12-13</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=The+Open+Group+Base+Specifications&amp;rft.atitle=Chapter+9%3A+Regular+Expressions&amp;rft.issue=6&amp;rft.date=2004&amp;rft_id=http%3A%2F%2Fpubs.opengroup.org%2Fonlinepubs%2F009695399%2Fbasedefs%2Fxbd_chap09.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFCox2007" class="citation web cs1">Cox, Russ (2007). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20100101190447/http://swtch.com/~rsc/regexp/regexp1.html">"Regular Expression Matching Can Be Simple and Fast"</a>. Archived from <a rel="nofollow" class="external text" href="https://swtch.com/~rsc/regexp/regexp1.html">the original</a> on 2010-01-01<span class="reference-accessdate">. Retrieved <span class="nowrap">2008-04-27</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Regular+Expression+Matching+Can+Be+Simple+and+Fast&amp;rft.date=2007&amp;rft.aulast=Cox&amp;rft.aufirst=Russ&amp;rft_id=https%3A%2F%2Fswtch.com%2F~rsc%2Fregexp%2Fregexp1.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFForta2004" class="citation book cs1"><a href="/wiki/Ben_Forta" title="Ben Forta">Forta, Ben</a> (2004). <i>Sams Teach Yourself Regular Expressions in 10 Minutes</i>. Sams. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-672-32566-3" title="Special:BookSources/978-0-672-32566-3"><bdi>978-0-672-32566-3</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Sams+Teach+Yourself+Regular+Expressions+in+10+Minutes&amp;rft.pub=Sams&amp;rft.date=2004&amp;rft.isbn=978-0-672-32566-3&amp;rft.aulast=Forta&amp;rft.aufirst=Ben&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFFriedl2002" class="citation book cs1">Friedl, Jeffrey E. F. (2002). <a rel="nofollow" class="external text" href="http://regex.info/"><i>Mastering Regular Expressions</i></a>. <a href="/wiki/O%27Reilly_Media" title="O&#39;Reilly Media">O'Reilly</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-596-00289-3" title="Special:BookSources/978-0-596-00289-3"><bdi>978-0-596-00289-3</bdi></a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20050830113350/http://regex.info/">Archived</a> from the original on 2005-08-30<span class="reference-accessdate">. Retrieved <span class="nowrap">2005-04-26</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Mastering+Regular+Expressions&amp;rft.pub=O%27Reilly&amp;rft.date=2002&amp;rft.isbn=978-0-596-00289-3&amp;rft.aulast=Friedl&amp;rft.aufirst=Jeffrey+E.+F.&amp;rft_id=http%3A%2F%2Fregex.info%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFGeladeNeven2008" class="citation conference cs1">Gelade, Wouter; Neven, Frank (2008). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110718225605/http://drops.dagstuhl.de/opus/volltexte/2008/1354/"><i>Succinctness of the Complement and Intersection of Regular Expressions</i></a>. <i>Proceedings of the 25th International Symposium on Theoretical Aspects of Computer Science (STACS 2008)</i>. pp.&#160;325–336. <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/0802.2869">0802.2869</a></span>. Archived from <a rel="nofollow" class="external text" href="http://drops.dagstuhl.de/opus/volltexte/2008/1354">the original</a> on 2011-07-18<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-06-15</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=conference&amp;rft.jtitle=Proceedings+of+the+25th+International+Symposium+on+Theoretical+Aspects+of+Computer+Science+%28STACS+2008%29&amp;rft.atitle=Succinctness+of+the+Complement+and+Intersection+of+Regular+Expressions&amp;rft.pages=325-336&amp;rft.date=2008&amp;rft_id=info%3Aarxiv%2F0802.2869&amp;rft.aulast=Gelade&amp;rft.aufirst=Wouter&amp;rft.au=Neven%2C+Frank&amp;rft_id=http%3A%2F%2Fdrops.dagstuhl.de%2Fopus%2Fvolltexte%2F2008%2F1354&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFGoyvaertsLevithan2009" class="citation book cs1">Goyvaerts, Jan; Levithan, Steven (2009). <i>Regular Expressions Cookbook</i>. [O'reilly]. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-596-52068-7" title="Special:BookSources/978-0-596-52068-7"><bdi>978-0-596-52068-7</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Regular+Expressions+Cookbook&amp;rft.pub=%5BO%27reilly%5D&amp;rft.date=2009&amp;rft.isbn=978-0-596-52068-7&amp;rft.aulast=Goyvaerts&amp;rft.aufirst=Jan&amp;rft.au=Levithan%2C+Steven&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFGruberHolzer2008" class="citation conference cs1">Gruber, Hermann; Holzer, Markus (2008). <a rel="nofollow" class="external text" href="http://www.hermann-gruber.com/data/icalp08.pdf"><i>Finite Automata, Digraph Connectivity, and Regular Expression Size</i></a> <span class="cs1-format">(PDF)</span>. <i>Proceedings of the 35th International Colloquium on Automata, Languages and Programming (ICALP 2008)</i>. Lecture Notes in Computer Science. Vol.&#160;5126. pp.&#160;39–50. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-540-70583-3_4">10.1007/978-3-540-70583-3_4</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-3-540-70582-6" title="Special:BookSources/978-3-540-70582-6"><bdi>978-3-540-70582-6</bdi></a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110711163607/http://www.hermann-gruber.com/data/icalp08.pdf">Archived</a> <span class="cs1-format">(PDF)</span> from the original on 2011-07-11<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-02-03</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=conference&amp;rft.jtitle=Proceedings+of+the+35th+International+Colloquium+on+Automata%2C+Languages+and+Programming+%28ICALP+2008%29&amp;rft.atitle=Finite+Automata%2C+Digraph+Connectivity%2C+and+Regular+Expression+Size&amp;rft.volume=5126&amp;rft.pages=39-50&amp;rft.date=2008&amp;rft_id=info%3Adoi%2F10.1007%2F978-3-540-70583-3_4&amp;rft.isbn=978-3-540-70582-6&amp;rft.aulast=Gruber&amp;rft.aufirst=Hermann&amp;rft.au=Holzer%2C+Markus&amp;rft_id=http%3A%2F%2Fwww.hermann-gruber.com%2Fdata%2Ficalp08.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHabibi2004" class="citation book cs1">Habibi, Mehran (2004). <i>Real World Regular Expressions with Java 1.4</i>. Springer. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-1-59059-107-9" title="Special:BookSources/978-1-59059-107-9"><bdi>978-1-59059-107-9</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Real+World+Regular+Expressions+with+Java+1.4&amp;rft.pub=Springer&amp;rft.date=2004&amp;rft.isbn=978-1-59059-107-9&amp;rft.aulast=Habibi&amp;rft.aufirst=Mehran&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHopcroftMotwaniUllman2000" class="citation book cs1">Hopcroft, John E.; Motwani, Rajeev; Ullman, Jeffrey D. (2000). <i>Introduction to Automata Theory, Languages, and Computation</i> (2nd&#160;ed.). Addison-Wesley.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Introduction+to+Automata+Theory%2C+Languages%2C+and+Computation&amp;rft.edition=2nd&amp;rft.pub=Addison-Wesley&amp;rft.date=2000&amp;rft.aulast=Hopcroft&amp;rft.aufirst=John+E.&amp;rft.au=Motwani%2C+Rajeev&amp;rft.au=Ullman%2C+Jeffrey+D.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFJohnsonPorterAckleyRoss1968" class="citation journal cs1">Johnson, Walter L.; Porter, James H.; Ackley, Stephanie I.; Ross, Douglas T. (1968). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F364175.364185">"Automatic generation of efficient lexical processors using finite state techniques"</a>. <i>Communications of the ACM</i>. <b>11</b> (12): 805–813. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F364175.364185">10.1145/364175.364185</a></span>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:17253809">17253809</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Communications+of+the+ACM&amp;rft.atitle=Automatic+generation+of+efficient+lexical+processors+using+finite+state+techniques&amp;rft.volume=11&amp;rft.issue=12&amp;rft.pages=805-813&amp;rft.date=1968&amp;rft_id=info%3Adoi%2F10.1145%2F364175.364185&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A17253809%23id-name%3DS2CID&amp;rft.aulast=Johnson&amp;rft.aufirst=Walter+L.&amp;rft.au=Porter%2C+James+H.&amp;rft.au=Ackley%2C+Stephanie+I.&amp;rft.au=Ross%2C+Douglas+T.&amp;rft_id=https%3A%2F%2Fdoi.org%2F10.1145%252F364175.364185&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFKleene1951" class="citation book cs1">Kleene, Stephen C. (1951). "Representation of Events in Nerve Nets and Finite Automata". In Shannon, Claude E.; McCarthy, John (eds.). <a rel="nofollow" class="external text" href="https://www.rand.org/content/dam/rand/pubs/research_memoranda/2008/RM704.pdf"><i>Automata Studies</i></a> <span class="cs1-format">(PDF)</span>. Princeton University Press. pp.&#160;3–42. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201007183213/https://www.rand.org/content/dam/rand/pubs/research_memoranda/2008/RM704.pdf">Archived</a> <span class="cs1-format">(PDF)</span> from the original on 2020-10-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2017-12-10</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Representation+of+Events+in+Nerve+Nets+and+Finite+Automata&amp;rft.btitle=Automata+Studies&amp;rft.pages=3-42&amp;rft.pub=Princeton+University+Press&amp;rft.date=1951&amp;rft.aulast=Kleene&amp;rft.aufirst=Stephen+C.&amp;rft_id=https%3A%2F%2Fwww.rand.org%2Fcontent%2Fdam%2Frand%2Fpubs%2Fresearch_memoranda%2F2008%2FRM704.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFKozen1991" class="citation book cs1">Kozen, Dexter (1991). "A completeness theorem for Kleene algebras and the algebra of regular events". <i>&#91;1991&#93; Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science</i>. pp.&#160;214–225. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FLICS.1991.151646">10.1109/LICS.1991.151646</a>. <a href="/wiki/Hdl_(identifier)" class="mw-redirect" title="Hdl (identifier)">hdl</a>:<a rel="nofollow" class="external text" href="https://hdl.handle.net/1813%2F6963">1813/6963</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-8186-2230-4" title="Special:BookSources/978-0-8186-2230-4"><bdi>978-0-8186-2230-4</bdi></a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:19875225">19875225</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=A+completeness+theorem+for+Kleene+algebras+and+the+algebra+of+regular+events&amp;rft.btitle=%26%2391%3B1991%26%2393%3B+Proceedings+Sixth+Annual+IEEE+Symposium+on+Logic+in+Computer+Science&amp;rft.pages=214-225&amp;rft.date=1991&amp;rft_id=info%3Ahdl%2F1813%2F6963&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A19875225%23id-name%3DS2CID&amp;rft_id=info%3Adoi%2F10.1109%2FLICS.1991.151646&amp;rft.isbn=978-0-8186-2230-4&amp;rft.aulast=Kozen&amp;rft.aufirst=Dexter&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFLaurikari2009" class="citation web cs1">Laurikari, Ville (2009). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20100714224701/http://laurikari.net/tre/">"TRE library 0.7.6"</a>. Archived from <a rel="nofollow" class="external text" href="https://www.laurikari.net/tre/">the original</a> on 2010-07-14<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-04-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=TRE+library+0.7.6&amp;rft.date=2009&amp;rft.aulast=Laurikari&amp;rft.aufirst=Ville&amp;rft_id=http%3A%2F%2Fwww.laurikari.net%2Ftre%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFLigerMcQueenWilton2002" class="citation book cs1">Liger, François; McQueen, Craig; Wilton, Paul (2002). <i>Visual Basic .NET Text Manipulation Handbook</i>. <a href="/wiki/Wrox_Press" title="Wrox Press">Wrox Press</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-1-86100-730-8" title="Special:BookSources/978-1-86100-730-8"><bdi>978-1-86100-730-8</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Visual+Basic+.NET+Text+Manipulation+Handbook&amp;rft.pub=Wrox+Press&amp;rft.date=2002&amp;rft.isbn=978-1-86100-730-8&amp;rft.aulast=Liger&amp;rft.aufirst=Fran%C3%A7ois&amp;rft.au=McQueen%2C+Craig&amp;rft.au=Wilton%2C+Paul&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFSipser1998" class="citation book cs1"><a href="/wiki/Michael_Sipser" title="Michael Sipser">Sipser, Michael</a> (1998). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/introductiontoth00sips/page/31">"Chapter 1: Regular Languages"</a></span>. <i>Introduction to the Theory of Computation</i>. PWS Publishing. pp.&#160;<a rel="nofollow" class="external text" href="https://archive.org/details/introductiontoth00sips/page/31">31–90</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-534-94728-6" title="Special:BookSources/978-0-534-94728-6"><bdi>978-0-534-94728-6</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Chapter+1%3A+Regular+Languages&amp;rft.btitle=Introduction+to+the+Theory+of+Computation&amp;rft.pages=31-90&amp;rft.pub=PWS+Publishing&amp;rft.date=1998&amp;rft.isbn=978-0-534-94728-6&amp;rft.aulast=Sipser&amp;rft.aufirst=Michael&amp;rft_id=https%3A%2F%2Farchive.org%2Fdetails%2Fintroductiontoth00sips%2Fpage%2F31&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFStubblebine2003" class="citation book cs1">Stubblebine, Tony (2003). <i>Regular Expression Pocket Reference</i>. O'Reilly. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-596-00415-6" title="Special:BookSources/978-0-596-00415-6"><bdi>978-0-596-00415-6</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Regular+Expression+Pocket+Reference&amp;rft.pub=O%27Reilly&amp;rft.date=2003&amp;rft.isbn=978-0-596-00415-6&amp;rft.aulast=Stubblebine&amp;rft.aufirst=Tony&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFThompson1968" class="citation journal cs1"><a href="/wiki/Ken_Thompson" title="Ken Thompson">Thompson, Ken</a> (1968). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F363347.363387">"Programming Techniques: Regular expression search algorithm"</a>. <i>Communications of the ACM</i>. <b>11</b> (6): 419–422. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F363347.363387">10.1145/363347.363387</a></span>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:21260384">21260384</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Communications+of+the+ACM&amp;rft.atitle=Programming+Techniques%3A+Regular+expression+search+algorithm&amp;rft.volume=11&amp;rft.issue=6&amp;rft.pages=419-422&amp;rft.date=1968&amp;rft_id=info%3Adoi%2F10.1145%2F363347.363387&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A21260384%23id-name%3DS2CID&amp;rft.aulast=Thompson&amp;rft.aufirst=Ken&amp;rft_id=https%3A%2F%2Fdoi.org%2F10.1145%252F363347.363387&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFWall2002" class="citation web cs1"><a href="/wiki/Larry_Wall" title="Larry Wall">Wall, Larry</a> (2002). <a rel="nofollow" class="external text" href="http://dev.perl.org/perl6/doc/design/apo/A05.html">"Apocalypse 5: Pattern Matching"</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20100112232513/http://dev.perl.org/perl6/doc/design/apo/A05.html">Archived</a> from the original on 2010-01-12<span class="reference-accessdate">. Retrieved <span class="nowrap">2006-10-11</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Apocalypse+5%3A+Pattern+Matching&amp;rft.date=2002&amp;rft.aulast=Wall&amp;rft.aufirst=Larry&amp;rft_id=http%3A%2F%2Fdev.perl.org%2Fperl6%2Fdoc%2Fdesign%2Fapo%2FA05.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ARegular+expression" class="Z3988"></span></li></ul> </div> <div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Regular_expression&amp;action=edit&amp;section=29" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1235681985">.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}</style><style data-mw-deduplicate="TemplateStyles:r1237033735">@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}</style><div class="side-box side-box-right plainlinks sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}</style> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/60px-Wikibooks-logo-en-noslogan.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/80px-Wikibooks-logo-en-noslogan.svg.png 2x" data-file-width="400" data-file-height="400" /></span></span></div> <div class="side-box-text plainlist">Wikibooks has a book on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Regular_Expressions" class="extiw" title="wikibooks:Regular Expressions">Regular Expressions</a></b></i></div></div> </div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1235681985"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1237033735"><div class="side-box side-box-right plainlinks sistersitebox"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1126788409"> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/60px-Wikibooks-logo-en-noslogan.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/80px-Wikibooks-logo-en-noslogan.svg.png 2x" data-file-width="400" data-file-height="400" /></span></span></div> <div class="side-box-text plainlist">The Wikibook <i><a href="https://en.wikibooks.org/wiki/R_Programming" class="extiw" title="wikibooks:R Programming">R Programming</a></i> has a page on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/R_Programming/Text_Processing" class="extiw" title="wikibooks:R Programming/Text Processing">Text Processing</a></b></i></div></div> </div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1235681985"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1237033735"><div class="side-box side-box-right plainlinks sistersitebox"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1126788409"> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/9/99/Wiktionary-logo-en-v2.svg/40px-Wiktionary-logo-en-v2.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/9/99/Wiktionary-logo-en-v2.svg/60px-Wiktionary-logo-en-v2.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/9/99/Wiktionary-logo-en-v2.svg/80px-Wiktionary-logo-en-v2.svg.png 2x" data-file-width="512" data-file-height="512" /></span></span></div> <div class="side-box-text plainlist">Look up <i><b><a href="https://en.wiktionary.org/wiki/regular_expression" class="extiw" title="wiktionary:regular expression">regular expression</a></b></i> in Wiktionary, the free dictionary.</div></div> </div> <ul><li><span class="noviewer" typeof="mw:File"><a href="/wiki/File:Commons-logo.svg" class="mw-file-description"><img alt="" src="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/12px-Commons-logo.svg.png" decoding="async" width="12" height="16" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/18px-Commons-logo.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/24px-Commons-logo.svg.png 2x" data-file-width="1024" data-file-height="1376" /></a></span> Media related to <a href="https://commons.wikimedia.org/wiki/Category:Regex" class="extiw" title="commons:Category:Regex">Regex</a> at Wikimedia Commons</li> <li>ISO/IEC 9945-2:1993 <a rel="nofollow" class="external text" href="http://www.iso.org/iso/catalogue_detail.htm?csnumber=17841"><i>Information technology – Portable Operating System Interface (POSIX) – Part 2: Shell and Utilities</i></a></li> <li>ISO/IEC 9945-2:2002 <a rel="nofollow" class="external text" href="http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?csnumber=37313"><i>Information technology – Portable Operating System Interface (POSIX) – Part 2: System Interfaces</i></a></li> <li>ISO/IEC 9945-2:2003 <a rel="nofollow" class="external text" href="http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?csnumber=38790"><i>Information technology – Portable Operating System Interface (POSIX) – Part 2: System Interfaces</i></a></li> <li>ISO/IEC/IEEE 9945:2009 <a rel="nofollow" class="external text" href="http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?csnumber=50516"><i>Information technology – Portable Operating System Interface (POSIX) Base Specifications, Issue 7</i></a></li> <li><a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html">Regular Expression, IEEE Std 1003.1-2017, Open Group</a></li></ul> <div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}</style><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1126788409"><style data-mw-deduplicate="TemplateStyles:r1236075235">.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}</style></div><div role="navigation" class="navbox" aria-labelledby="Automata_theory:_formal_languages_and_formal_grammars" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374"><style data-mw-deduplicate="TemplateStyles:r1239400231">.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}</style><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:Formal_languages_and_grammars" title="Template:Formal languages and grammars"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:Formal_languages_and_grammars" title="Template talk:Formal languages and grammars"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:Formal_languages_and_grammars" title="Special:EditPage/Template:Formal languages and grammars"><abbr title="Edit this template">e</abbr></a></li></ul></div><div id="Automata_theory:_formal_languages_and_formal_grammars" style="font-size:114%;margin:0 4em"><a href="/wiki/Automata_theory" title="Automata theory">Automata theory</a>: <a href="/wiki/Formal_language" title="Formal language">formal languages</a> and <a href="/wiki/Formal_grammar" title="Formal grammar">formal grammars</a></div></th></tr><tr><td colspan="2" class="navbox-list navbox-odd plainlist" style="width:100%;padding:0;background:transparent;color:inherit;"><div style="padding:0px"><table class="navbox-columns-table" style="border-spacing: 0px; text-align:left;width:100%;"><tbody><tr><td class="navbox-abovebelow" style="font-weight:bold;"><a href="/wiki/Chomsky_hierarchy" title="Chomsky hierarchy">Chomsky hierarchy</a></td><td class="navbox-abovebelow" style="border-left:2px solid #fdfdfd;font-weight:bold;"><a href="/wiki/Formal_grammar" title="Formal grammar">Grammars</a></td><td class="navbox-abovebelow" style="border-left:2px solid #fdfdfd;font-weight:bold;"><a href="/wiki/Formal_language" title="Formal language">Languages</a></td><td class="navbox-abovebelow" style="border-left:2px solid #fdfdfd;font-weight:bold;"><a href="/wiki/Abstract_machine" title="Abstract machine">Abstract machines</a></td></tr><tr style="vertical-align:top"><td class="navbox-list" style="padding:0px;text-align: center;width:10em;"><div> <ul><li>Type-0</li> <li>—</li> <li>Type-1</li> <li>—</li> <li>—</li> <li>—</li> <li>—</li> <li>—</li> <li>Type-2</li> <li>—</li> <li>—</li> <li>Type-3</li> <li>—</li> <li>—</li></ul> </div></td><td class="navbox-list" style="border-left:2px solid #fdfdfd;padding:0px;width:10em;"><div> <ul><li><a href="/wiki/Unrestricted_grammar" title="Unrestricted grammar">Unrestricted</a></li> <li>(no common name)</li> <li><a href="/wiki/Context-sensitive_grammar" title="Context-sensitive grammar">Context-sensitive</a></li> <li><span style="white-space:nowrap;">Positive <a href="/wiki/Range_concatenation_grammars" class="mw-redirect" title="Range concatenation grammars">range concatenation</a></span></li> <li><a href="/wiki/Indexed_grammar" title="Indexed grammar">Indexed</a></li> <li>—</li> <li><a href="/wiki/Linear_context-free_rewriting_system" class="mw-redirect" title="Linear context-free rewriting system">Linear context-free rewriting systems</a></li> <li><a href="/wiki/Tree-adjoining_grammar" title="Tree-adjoining grammar">Tree-adjoining</a></li> <li><a href="/wiki/Context-free_grammar" title="Context-free grammar">Context-free</a></li> <li><a href="/wiki/Deterministic_context-free_grammar" title="Deterministic context-free grammar">Deterministic context-free</a></li> <li><a href="/wiki/Nested_word" title="Nested word">Visibly pushdown</a></li> <li><a href="/wiki/Regular_grammar" title="Regular grammar">Regular</a></li> <li>—</li> <li><a href="/wiki/Non-recursive_grammar" class="mw-redirect" title="Non-recursive grammar">Non-recursive</a></li></ul> </div></td><td class="navbox-list" style="border-left:2px solid #fdfdfd;padding:0px;width:10em;"><div> <ul><li><a href="/wiki/Recursively_enumerable_language" title="Recursively enumerable language">Recursively enumerable</a></li> <li><a href="/wiki/Recursive_language" title="Recursive language">Decidable</a></li> <li><a href="/wiki/Context-sensitive_language" title="Context-sensitive language">Context-sensitive</a></li> <li><span style="white-space:nowrap;">Positive <a href="/wiki/Range_concatenation_language" class="mw-redirect" title="Range concatenation language">range concatenation</a><sup>*</sup></span></li> <li><a href="/wiki/Indexed_language" title="Indexed language">Indexed</a><sup>*</sup></li> <li>—</li> <li><a href="/wiki/Linear_context-free_rewriting_language" class="mw-redirect" title="Linear context-free rewriting language">Linear context-free rewriting language</a></li> <li><a href="/wiki/Tree-adjoining_grammar" title="Tree-adjoining grammar">Tree-adjoining</a></li> <li><a href="/wiki/Context-free_language" title="Context-free language">Context-free</a></li> <li><a href="/wiki/Deterministic_context-free_language" title="Deterministic context-free language">Deterministic context-free</a></li> <li><a href="/wiki/Nested_word" title="Nested word">Visibly pushdown</a></li> <li><a href="/wiki/Regular_language" title="Regular language">Regular</a></li> <li><a href="/wiki/Star-free_language" title="Star-free language">Star-free</a></li> <li><a href="/wiki/Finite_language" class="mw-redirect" title="Finite language">Finite</a></li></ul> </div></td><td class="navbox-list" style="border-left:2px solid #fdfdfd;padding:0px;width:10em;"><div> <ul><li><a href="/wiki/Turing_machine" title="Turing machine">Turing machine</a></li> <li><a href="/wiki/Decider_(Turing_machine)" title="Decider (Turing machine)">Decider</a></li> <li><a href="/wiki/Linear_bounded_automaton" title="Linear bounded automaton">Linear-bounded</a></li> <li><a href="/wiki/PTIME" class="mw-redirect" title="PTIME">PTIME</a> Turing Machine</li> <li><a href="/wiki/Nested_stack_automaton" title="Nested stack automaton">Nested stack</a></li> <li><a href="/wiki/Thread_automaton" title="Thread automaton">Thread automaton</a></li> <li>restricted <a href="/wiki/Tree_stack_automaton" title="Tree stack automaton">Tree stack automaton</a></li> <li><a href="/wiki/Embedded_pushdown_automaton" title="Embedded pushdown automaton">Embedded pushdown</a></li> <li><a href="/wiki/Pushdown_automaton" title="Pushdown automaton">Nondeterministic pushdown</a></li> <li><a href="/wiki/Deterministic_pushdown_automaton" title="Deterministic pushdown automaton">Deterministic pushdown</a></li> <li><a href="/wiki/Nested_word" title="Nested word">Visibly pushdown</a></li> <li><a href="/wiki/Finite-state_machine" title="Finite-state machine">Finite</a></li> <li><a href="/wiki/Aperiodic_finite_state_automaton" title="Aperiodic finite state automaton">Counter-free (with aperiodic finite monoid)</a></li> <li><a href="/wiki/Deterministic_acyclic_finite_state_automaton" title="Deterministic acyclic finite state automaton">Acyclic finite</a></li></ul> </div></td></tr></tbody></table></div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div><span style="white-space:nowrap;">Each category of languages, except those marked by a <sup>*</sup>, is a <a href="/wiki/Proper_subset" class="mw-redirect" title="Proper subset">proper subset</a> of the category directly above it.</span> <span style="white-space:nowrap;">Any language in each category is generated by a grammar and by an automaton in the category in the same line.</span></div></td></tr></tbody></table></div> <div class="navbox-styles"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236075235"></div><div role="navigation" class="navbox" aria-labelledby="Strings" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1239400231"><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:Strings" title="Template:Strings"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:Strings" title="Template talk:Strings"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:Strings" title="Special:EditPage/Template:Strings"><abbr title="Edit this template">e</abbr></a></li></ul></div><div id="Strings" style="font-size:114%;margin:0 4em"><a href="/wiki/String_(computer_science)" title="String (computer science)">Strings</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/String_metric" title="String metric">String metric</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Approximate_string_matching" title="Approximate string matching">Approximate string matching</a></li> <li><a href="/wiki/Bitap_algorithm" title="Bitap algorithm">Bitap algorithm</a></li> <li><a href="/wiki/Damerau%E2%80%93Levenshtein_distance" title="Damerau–Levenshtein distance">Damerau–Levenshtein distance</a></li> <li><a href="/wiki/Edit_distance" title="Edit distance">Edit distance</a></li> <li><a href="/wiki/Gestalt_pattern_matching" title="Gestalt pattern matching">Gestalt pattern matching</a></li> <li><a href="/wiki/Hamming_distance" title="Hamming distance">Hamming distance</a></li> <li><a href="/wiki/Jaro%E2%80%93Winkler_distance" title="Jaro–Winkler distance">Jaro–Winkler distance</a></li> <li><a href="/wiki/Lee_distance" title="Lee distance">Lee distance</a></li> <li><a href="/wiki/Levenshtein_automaton" title="Levenshtein automaton">Levenshtein automaton</a></li> <li><a href="/wiki/Levenshtein_distance" title="Levenshtein distance">Levenshtein distance</a></li> <li><a href="/wiki/Wagner%E2%80%93Fischer_algorithm" title="Wagner–Fischer algorithm">Wagner–Fischer algorithm </a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/String-searching_algorithm" title="String-searching algorithm">String-searching algorithm</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Apostolico%E2%80%93Giancarlo_algorithm" title="Apostolico–Giancarlo algorithm">Apostolico–Giancarlo algorithm</a></li> <li><a href="/wiki/Boyer%E2%80%93Moore_string-search_algorithm" title="Boyer–Moore string-search algorithm">Boyer–Moore string-search algorithm</a></li> <li><a href="/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm" title="Boyer–Moore–Horspool algorithm">Boyer–Moore–Horspool algorithm</a></li> <li><a href="/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm" title="Knuth–Morris–Pratt algorithm">Knuth–Morris–Pratt algorithm</a></li> <li><a href="/wiki/Rabin%E2%80%93Karp_algorithm" title="Rabin–Karp algorithm">Rabin–Karp algorithm</a></li> <li><a href="/wiki/Raita_algorithm" title="Raita algorithm">Raita algorithm</a></li> <li><a href="/wiki/Trigram_search" title="Trigram search">Trigram search</a></li> <li><a href="/wiki/Two-way_string-matching_algorithm" title="Two-way string-matching algorithm">Two-way string-matching algorithm</a></li> <li><a href="/wiki/Zhu%E2%80%93Takaoka_string_matching_algorithm" title="Zhu–Takaoka string matching algorithm">Zhu–Takaoka string matching algorithm</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Multiple string searching</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Aho%E2%80%93Corasick_algorithm" title="Aho–Corasick algorithm">Aho–Corasick</a></li> <li><a href="/wiki/Commentz-Walter_algorithm" title="Commentz-Walter algorithm">Commentz-Walter algorithm</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a class="mw-selflink selflink">Regular expression</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Comparison_of_regular-expression_engines" class="mw-redirect" title="Comparison of regular-expression engines">Comparison of regular-expression engines</a></li> <li><a href="/wiki/Regular_grammar" title="Regular grammar">Regular grammar</a></li> <li><a href="/wiki/Thompson%27s_construction" title="Thompson&#39;s construction">Thompson's construction</a></li> <li><a href="/wiki/Nondeterministic_finite_automaton" title="Nondeterministic finite automaton">Nondeterministic finite automaton</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Sequence_alignment" title="Sequence alignment">Sequence alignment</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/BLAST_(biotechnology)" title="BLAST (biotechnology)">BLAST</a></li> <li><a href="/wiki/Hirschberg%27s_algorithm" title="Hirschberg&#39;s algorithm">Hirschberg's algorithm</a></li> <li><a href="/wiki/Needleman%E2%80%93Wunsch_algorithm" title="Needleman–Wunsch algorithm">Needleman–Wunsch algorithm</a></li> <li><a href="/wiki/Smith%E2%80%93Waterman_algorithm" title="Smith–Waterman algorithm">Smith–Waterman algorithm</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Data_structure" title="Data structure">Data structure</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Deterministic_acyclic_finite_state_automaton" title="Deterministic acyclic finite state automaton">DAFSA</a></li> <li><a href="/wiki/Suffix_array" title="Suffix array">Suffix array</a></li> <li><a href="/wiki/Suffix_automaton" title="Suffix automaton">Suffix automaton</a></li> <li><a href="/wiki/Suffix_tree" title="Suffix tree">Suffix tree</a></li> <li><a href="/wiki/Generalized_suffix_tree" title="Generalized suffix tree">Generalized suffix tree</a></li> <li><a href="/wiki/Rope_(data_structure)" title="Rope (data structure)">Rope</a></li> <li><a href="/wiki/Ternary_search_tree" title="Ternary search tree">Ternary search tree</a></li> <li><a href="/wiki/Trie" title="Trie">Trie</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Parsing" title="Parsing">Parsing</a></li> <li><a href="/wiki/Pattern_matching" title="Pattern matching">Pattern matching</a></li> <li><a href="/wiki/Compressed_pattern_matching" title="Compressed pattern matching">Compressed pattern matching</a></li> <li><a href="/wiki/Longest_common_subsequence" title="Longest common subsequence">Longest common subsequence</a></li> <li><a href="/wiki/Longest_common_substring" title="Longest common substring">Longest common substring</a></li> <li><a href="/wiki/Sequential_pattern_mining" title="Sequential pattern mining">Sequential pattern mining</a></li> <li><a href="/wiki/Category:String_sorting_algorithms" title="Category:String sorting algorithms">Sorting</a></li> <li><a href="/wiki/Semi-Thue_system" title="Semi-Thue system">String rewriting systems</a></li> <li><a href="/wiki/String_operations" title="String operations">String operations</a></li></ul> </div></td></tr></tbody></table></div> <div class="navbox-styles"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236075235"><style data-mw-deduplicate="TemplateStyles:r1038841319">.mw-parser-output .tooltip-dotted{border-bottom:1px dotted;cursor:help}</style></div><div role="navigation" class="navbox authority-control" aria-label="Navbox" style="padding:3px"><table class="nowraplinks hlist navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Help:Authority_control" title="Help:Authority control">Authority control databases</a>: National <span class="mw-valign-text-top noprint" typeof="mw:File/Frameless"><a href="https://www.wikidata.org/wiki/Q185612#identifiers" title="Edit this at Wikidata"><img alt="Edit this at Wikidata" src="//upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png" decoding="async" width="10" height="10" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/15px-OOjs_UI_icon_edit-ltr-progressive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/20px-OOjs_UI_icon_edit-ltr-progressive.svg.png 2x" data-file-width="20" data-file-height="20" /></a></span></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://d-nb.info/gnd/4506116-6">Germany</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://id.loc.gov/authorities/sh2018002310">United States</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://catalogue.bnf.fr/ark:/12148/cb14626171d">France</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://data.bnf.fr/ark:/12148/cb14626171d">BnF data</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://id.ndl.go.jp/auth/ndlna/01121341">Japan</a></span></li><li><span class="uid"><span class="rt-commentedText tooltip tooltip-dotted" title="regulární výrazy"><a rel="nofollow" class="external text" href="https://aleph.nkp.cz/F/?func=find-c&amp;local_base=aut&amp;ccl_term=ica=ph594494&amp;CON_LNG=ENG">Czech Republic</a></span></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="http://olduli.nli.org.il/F/?func=find-b&amp;local_base=NLX10&amp;find_code=UID&amp;request=987012575112805171">Israel</a></span></li></ul></div></td></tr></tbody></table></div> <!-- NewPP limit report Parsed by mw‐web.codfw.main‐5857dfdcd6‐5j4dg Cached time: 20241203065131 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 1.194 seconds Real time usage: 1.759 seconds Preprocessor visited node count: 8240/1000000 Post‐expand include size: 174724/2097152 bytes Template argument size: 6260/2097152 bytes Highest expansion depth: 19/100 Expensive parser function count: 142/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 280175/5000000 bytes Lua time usage: 0.677/10.000 seconds Lua memory usage: 8962566/52428800 bytes Number of Wikibase entities loaded: 1/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 1518.827 1 -total 26.61% 404.165 1 Template:Reflist 14.50% 220.233 31 Template:Cite_web 6.97% 105.864 20 Template:Cite_book 6.15% 93.432 8 Template:Sfn 6.07% 92.258 1 Template:Short_description 5.56% 84.436 1 Template:Formal_languages_and_grammars 5.45% 82.760 1 Template:Navbox_with_columns 4.55% 69.036 2 Template:Pagetype 3.45% 52.432 3 Template:Fix --> <!-- Saved in parser cache with key enwiki:pcache:25717:|#|:idhash:canonical and timestamp 20241203065131 and revision id 1255611009. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1&amp;useformat=desktop" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Regular_expression&amp;oldid=1255611009">https://en.wikipedia.org/w/index.php?title=Regular_expression&amp;oldid=1255611009</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Categories</a>: <ul><li><a href="/wiki/Category:Regular_expressions" title="Category:Regular expressions">Regular expressions</a></li><li><a href="/wiki/Category:1951_introductions" title="Category:1951 introductions">1951 introductions</a></li><li><a href="/wiki/Category:Automata_(computation)" title="Category:Automata (computation)">Automata (computation)</a></li><li><a href="/wiki/Category:Formal_languages" title="Category:Formal languages">Formal languages</a></li><li><a href="/wiki/Category:Pattern_matching" title="Category:Pattern matching">Pattern matching</a></li><li><a href="/wiki/Category:Programming_constructs" title="Category:Programming constructs">Programming constructs</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Wikipedia_articles_needing_page_number_citations_from_February_2015" title="Category:Wikipedia articles needing page number citations from February 2015">Wikipedia articles needing page number citations from February 2015</a></li><li><a href="/wiki/Category:CS1_Russian-language_sources_(ru)" title="Category:CS1 Russian-language sources (ru)">CS1 Russian-language sources (ru)</a></li><li><a href="/wiki/Category:Webarchive_template_wayback_links" title="Category:Webarchive template wayback links">Webarchive template wayback links</a></li><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_matches_Wikidata" title="Category:Short description matches Wikidata">Short description matches Wikidata</a></li><li><a href="/wiki/Category:All_articles_with_unsourced_statements" title="Category:All articles with unsourced statements">All articles with unsourced statements</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_June_2023" title="Category:Articles with unsourced statements from June 2023">Articles with unsourced statements from June 2023</a></li><li><a href="/wiki/Category:Articles_containing_potentially_dated_statements_from_2016" title="Category:Articles containing potentially dated statements from 2016">Articles containing potentially dated statements from 2016</a></li><li><a href="/wiki/Category:All_articles_containing_potentially_dated_statements" title="Category:All articles containing potentially dated statements">All articles containing potentially dated statements</a></li><li><a href="/wiki/Category:Commons_category_link_is_on_Wikidata" title="Category:Commons category link is on Wikidata">Commons category link is on Wikidata</a></li><li><a href="/wiki/Category:Articles_with_example_code" title="Category:Articles with example code">Articles with example code</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 5 November 2024, at 20:36<span class="anonymous-show">&#160;(UTC)</span>.</li> <li id="footer-info-copyright">Text is available under the <a href="/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" title="Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License">Creative Commons Attribution-ShareAlike 4.0 License</a>; additional terms may apply. By using this site, you agree to the <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use" class="extiw" title="foundation:Special:MyLanguage/Policy:Terms of Use">Terms of Use</a> and <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy" class="extiw" title="foundation:Special:MyLanguage/Policy:Privacy policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a rel="nofollow" class="external text" href="https://wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Regular_expression&amp;mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-6dfcdd5ff5-sg7v7","wgBackendResponseTime":178,"wgPageParseReport":{"limitreport":{"cputime":"1.194","walltime":"1.759","ppvisitednodes":{"value":8240,"limit":1000000},"postexpandincludesize":{"value":174724,"limit":2097152},"templateargumentsize":{"value":6260,"limit":2097152},"expansiondepth":{"value":19,"limit":100},"expensivefunctioncount":{"value":142,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":280175,"limit":5000000},"entityaccesscount":{"value":1,"limit":400},"timingprofile":["100.00% 1518.827 1 -total"," 26.61% 404.165 1 Template:Reflist"," 14.50% 220.233 31 Template:Cite_web"," 6.97% 105.864 20 Template:Cite_book"," 6.15% 93.432 8 Template:Sfn"," 6.07% 92.258 1 Template:Short_description"," 5.56% 84.436 1 Template:Formal_languages_and_grammars"," 5.45% 82.760 1 Template:Navbox_with_columns"," 4.55% 69.036 2 Template:Pagetype"," 3.45% 52.432 3 Template:Fix"]},"scribunto":{"limitreport-timeusage":{"value":"0.677","limit":"10.000"},"limitreport-memusage":{"value":8962566,"limit":52428800},"limitreport-logs":"anchor_id_list = table#1 {\n [\"CITEREFAho1990\"] = 1,\n [\"CITEREFAhoUllman1992\"] = 1,\n [\"CITEREFAycock2003\"] = 1,\n [\"CITEREFBormannBray\"] = 1,\n [\"CITEREFCezar_CâmpeanuKai_SalomaaSheng_Yu2003\"] = 1,\n [\"CITEREFConway2005\"] = 1,\n [\"CITEREFCox2007\"] = 1,\n [\"CITEREFForta2004\"] = 1,\n [\"CITEREFFriedl2002\"] = 1,\n [\"CITEREFGeladeNeven2008\"] = 1,\n [\"CITEREFGischer1984\"] = 1,\n [\"CITEREFGoyvaerts\"] = 1,\n [\"CITEREFGoyvaertsLevithan2009\"] = 1,\n [\"CITEREFGruberHolzer2008\"] = 1,\n [\"CITEREFHabibi2004\"] = 1,\n [\"CITEREFHeddings2020\"] = 1,\n [\"CITEREFHopcroftMotwaniUllman2000\"] = 1,\n [\"CITEREFHopcroftMotwaniUllman2003\"] = 1,\n [\"CITEREFHorowitz2011\"] = 1,\n [\"CITEREFJohnsonPorterAckleyRoss1968\"] = 1,\n [\"CITEREFKearns2013\"] = 1,\n [\"CITEREFKernighan2007\"] = 1,\n [\"CITEREFKerrisk\"] = 1,\n [\"CITEREFKleene1951\"] = 1,\n [\"CITEREFKozen1991\"] = 1,\n [\"CITEREFLaurikari2009\"] = 1,\n [\"CITEREFLawson2003\"] = 1,\n [\"CITEREFLeung2010\"] = 1,\n [\"CITEREFLigerMcQueenWilton2002\"] = 1,\n [\"CITEREFMitkov2003\"] = 1,\n [\"CITEREFNavarro2001\"] = 1,\n [\"CITEREFRaymond,_Eric_S._citing_Dennis_Ritchie2003\"] = 1,\n [\"CITEREFRedko1964\"] = 1,\n [\"CITEREFRitchie\"] = 1,\n [\"CITEREFRitchieThompson1970\"] = 1,\n [\"CITEREFRuss_Cox2009\"] = 1,\n [\"CITEREFSchmid2019\"] = 1,\n [\"CITEREFSipser1998\"] = 1,\n [\"CITEREFStubblebine2003\"] = 1,\n [\"CITEREFThompson1968\"] = 1,\n [\"CITEREFWall,_Larry2006\"] = 1,\n [\"CITEREFWall1994\"] = 1,\n [\"CITEREFWall2002\"] = 1,\n [\"CITEREFWandering_Logic\"] = 1,\n [\"CITEREFZakharevich1997\"] = 1,\n}\ntemplate_list = table#1 {\n [\"!\"] = 6,\n [\"As of\"] = 1,\n [\"Authority control\"] = 1,\n [\"Blockquote\"] = 1,\n [\"Box\"] = 4,\n [\"Citation needed\"] = 1,\n [\"Cite IETF\"] = 1,\n [\"Cite arXiv\"] = 2,\n [\"Cite book\"] = 20,\n [\"Cite conference\"] = 2,\n [\"Cite journal\"] = 7,\n [\"Cite report\"] = 1,\n [\"Cite web\"] = 31,\n [\"Code\"] = 5,\n [\"Commons category-inline\"] = 1,\n [\"Em\"] = 1,\n [\"Formal languages and grammars\"] = 1,\n [\"Harvtxt\"] = 9,\n [\"Javadoc:SE\"] = 1,\n [\"Legend\"] = 1,\n [\"Main\"] = 1,\n [\"Mono\"] = 6,\n [\"Nowrap\"] = 7,\n [\"Page needed\"] = 1,\n [\"R\"] = 1,\n [\"Redirect\"] = 2,\n [\"Refbegin\"] = 1,\n [\"Refend\"] = 1,\n [\"Reflist\"] = 1,\n [\"Section link\"] = 1,\n [\"See also\"] = 1,\n [\"Sfn\"] = 8,\n [\"Short description\"] = 1,\n [\"Strings\"] = 1,\n [\"Title missing\"] = 1,\n [\"Tmath\"] = 2,\n [\"Visible anchor\"] = 2,\n [\"Webarchive\"] = 1,\n [\"Wikibooks\"] = 2,\n [\"Wiktionary\"] = 1,\n}\narticle_whitelist = table#1 {\n}\nciteref_patterns = table#1 {\n}\n"},"cachereport":{"origin":"mw-web.codfw.main-5857dfdcd6-5j4dg","timestamp":"20241203065131","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Regular expression","url":"https:\/\/en.wikipedia.org\/wiki\/Regular_expression","sameAs":"http:\/\/www.wikidata.org\/entity\/Q185612","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q185612","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2001-09-04T13:33:26Z","dateModified":"2024-11-05T20:36:26Z","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/9\/97\/Antony08.gif","headline":"sequence of characters that forms a search pattern"}</script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10