CINXE.COM

Perl Compatible Regular Expressions - 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>Perl Compatible Regular Expressions - 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":"1bf4674e-a1f1-452f-8168-6de279b53290","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Perl_Compatible_Regular_Expressions","wgTitle":"Perl Compatible Regular Expressions","wgCurRevisionId":1254397976,"wgRevisionId":1254397976,"wgArticleId":1712290,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description matches Wikidata","Articles containing potentially dated statements from 2020","All articles containing potentially dated statements","Wikipedia articles in need of updating from September 2020","All Wikipedia articles in need of updating","Pattern matching","C (programming language) libraries","Perl","Regular expressions","Software using the BSD license"],"wgPageViewLanguage":"en", "wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Perl_Compatible_Regular_Expressions","wgRelevantArticleId":1712290,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"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":30000,"wgRelatedArticlesCompat":[],"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q125267", "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.cite.styles":"ready","ext.pygments":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.cite.ux-enhancements","ext.pygments.view","site","mediawiki.page.ready","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.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.pygments%2CwikimediaBadges%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.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 name="viewport" content="width=1120"> <meta property="og:title" content="Perl Compatible Regular Expressions - 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/Perl_Compatible_Regular_Expressions"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Perl_Compatible_Regular_Expressions&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/Perl_Compatible_Regular_Expressions"> <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-Perl_Compatible_Regular_Expressions rootpage-Perl_Compatible_Regular_Expressions 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=Perl+Compatible+Regular+Expressions" 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=Perl+Compatible+Regular+Expressions" 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=Perl+Compatible+Regular+Expressions" 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=Perl+Compatible+Regular+Expressions" 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-Features" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Features"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Features</span> </div> </a> <button aria-controls="toc-Features-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 Features subsection</span> </button> <ul id="toc-Features-sublist" class="vector-toc-list"> <li id="toc-Just-in-time_compiler_support" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Just-in-time_compiler_support"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.1</span> <span>Just-in-time compiler support</span> </div> </a> <ul id="toc-Just-in-time_compiler_support-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Flexible_memory_management" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Flexible_memory_management"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2</span> <span>Flexible memory management</span> </div> </a> <ul id="toc-Flexible_memory_management-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Consistent_escaping_rules" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Consistent_escaping_rules"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.3</span> <span>Consistent escaping rules</span> </div> </a> <ul id="toc-Consistent_escaping_rules-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Extended_character_classes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Extended_character_classes"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.4</span> <span>Extended character classes</span> </div> </a> <ul id="toc-Extended_character_classes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Minimal_matching_(a.k.a._&quot;ungreedy&quot;)" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Minimal_matching_(a.k.a._&quot;ungreedy&quot;)"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.5</span> <span>Minimal matching (a.k.a. "ungreedy")</span> </div> </a> <ul id="toc-Minimal_matching_(a.k.a._&quot;ungreedy&quot;)-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Unicode_character_properties" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Unicode_character_properties"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.6</span> <span>Unicode character properties</span> </div> </a> <ul id="toc-Unicode_character_properties-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Multiline_matching" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Multiline_matching"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.7</span> <span>Multiline matching</span> </div> </a> <ul id="toc-Multiline_matching-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Newline/linebreak_options" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Newline/linebreak_options"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.8</span> <span>Newline/linebreak options</span> </div> </a> <ul id="toc-Newline/linebreak_options-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Backslash-R_options" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Backslash-R_options"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.9</span> <span>Backslash-R options</span> </div> </a> <ul id="toc-Backslash-R_options-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Beginning_of_pattern_options" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Beginning_of_pattern_options"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.10</span> <span>Beginning of pattern options</span> </div> </a> <ul id="toc-Beginning_of_pattern_options-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Backreferences" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Backreferences"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.11</span> <span>Backreferences</span> </div> </a> <ul id="toc-Backreferences-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Named_subpatterns" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Named_subpatterns"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.12</span> <span>Named subpatterns</span> </div> </a> <ul id="toc-Named_subpatterns-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Subroutines" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Subroutines"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.13</span> <span>Subroutines</span> </div> </a> <ul id="toc-Subroutines-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Atomic_grouping" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Atomic_grouping"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.14</span> <span>Atomic grouping</span> </div> </a> <ul id="toc-Atomic_grouping-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Look-ahead_and_look-behind_assertions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Look-ahead_and_look-behind_assertions"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.15</span> <span>Look-ahead and look-behind assertions</span> </div> </a> <ul id="toc-Look-ahead_and_look-behind_assertions-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Escape_sequences_for_zero-width_assertions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Escape_sequences_for_zero-width_assertions"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.16</span> <span>Escape sequences for zero-width assertions</span> </div> </a> <ul id="toc-Escape_sequences_for_zero-width_assertions-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Comments" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Comments"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.17</span> <span>Comments</span> </div> </a> <ul id="toc-Comments-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Recursive_patterns" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Recursive_patterns"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.18</span> <span>Recursive patterns</span> </div> </a> <ul id="toc-Recursive_patterns-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Generic_callouts" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Generic_callouts"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.19</span> <span>Generic callouts</span> </div> </a> <ul id="toc-Generic_callouts-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Differences_from_Perl" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Differences_from_Perl"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Differences from Perl</span> </div> </a> <button aria-controls="toc-Differences_from_Perl-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 Differences from Perl subsection</span> </button> <ul id="toc-Differences_from_Perl-sublist" class="vector-toc-list"> <li id="toc-Until_release_10.30_recursive_matches_were_atomic_in_PCRE_and_non_atomic_in_Perl" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Until_release_10.30_recursive_matches_were_atomic_in_PCRE_and_non_atomic_in_Perl"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Until release 10.30 recursive matches were atomic in PCRE and non atomic in Perl</span> </div> </a> <ul id="toc-Until_release_10.30_recursive_matches_were_atomic_in_PCRE_and_non_atomic_in_Perl-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-The_value_of_a_capture_buffer_deriving_from_the_?_quantifier_(match_1_or_0_times)_when_nested_in_another_quantified_capture_buffer_is_different" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#The_value_of_a_capture_buffer_deriving_from_the_?_quantifier_(match_1_or_0_times)_when_nested_in_another_quantified_capture_buffer_is_different"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2</span> <span>The value of a capture buffer deriving from the ? quantifier (match 1 or 0 times) when nested in another quantified capture buffer is different</span> </div> </a> <ul id="toc-The_value_of_a_capture_buffer_deriving_from_the_?_quantifier_(match_1_or_0_times)_when_nested_in_another_quantified_capture_buffer_is_different-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PCRE_allows_named_capture_buffers_to_be_given_numeric_names;_Perl_requires_the_name_to_follow_the_rule_of_barewords" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PCRE_allows_named_capture_buffers_to_be_given_numeric_names;_Perl_requires_the_name_to_follow_the_rule_of_barewords"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3</span> <span>PCRE allows named capture buffers to be given numeric names; Perl requires the name to follow the rule of barewords</span> </div> </a> <ul id="toc-PCRE_allows_named_capture_buffers_to_be_given_numeric_names;_Perl_requires_the_name_to_follow_the_rule_of_barewords-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PCRE_allows_alternatives_within_lookbehind_to_be_different_lengths" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PCRE_allows_alternatives_within_lookbehind_to_be_different_lengths"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.4</span> <span>PCRE allows alternatives within lookbehind to be different lengths</span> </div> </a> <ul id="toc-PCRE_allows_alternatives_within_lookbehind_to_be_different_lengths-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PCRE_does_not_support_certain_&quot;experimental&quot;_Perl_constructs" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PCRE_does_not_support_certain_&quot;experimental&quot;_Perl_constructs"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.5</span> <span>PCRE does not support certain "experimental" Perl constructs</span> </div> </a> <ul id="toc-PCRE_does_not_support_certain_&quot;experimental&quot;_Perl_constructs-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PCRE_and_Perl_are_slightly_different_in_their_tolerance_of_erroneous_constructs" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PCRE_and_Perl_are_slightly_different_in_their_tolerance_of_erroneous_constructs"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.6</span> <span>PCRE and Perl are slightly different in their tolerance of erroneous constructs</span> </div> </a> <ul id="toc-PCRE_and_Perl_are_slightly_different_in_their_tolerance_of_erroneous_constructs-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PCRE_has_a_hard_limit_on_recursion_depth,_Perl_does_not" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PCRE_has_a_hard_limit_on_recursion_depth,_Perl_does_not"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.7</span> <span>PCRE has a hard limit on recursion depth, Perl does not</span> </div> </a> <ul id="toc-PCRE_has_a_hard_limit_on_recursion_depth,_Perl_does_not-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Verification" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Verification"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.8</span> <span>Verification</span> </div> </a> <ul id="toc-Verification-sublist" class="vector-toc-list"> </ul> </li> </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">3</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Notes_and_references" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Notes_and_references"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Notes and references</span> </div> </a> <button aria-controls="toc-Notes_and_references-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 Notes and references subsection</span> </button> <ul id="toc-Notes_and_references-sublist" class="vector-toc-list"> <li id="toc-Notes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Notes"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</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-2"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> </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">5</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">Perl Compatible Regular Expressions</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 11 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-11" 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">11 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-cs mw-list-item"><a href="https://cs.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions" title="Perl Compatible Regular Expressions – Czech" lang="cs" hreflang="cs" data-title="Perl Compatible Regular Expressions" 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-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions" title="Perl Compatible Regular Expressions – German" lang="de" hreflang="de" data-title="Perl Compatible Regular Expressions" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions" title="Perl Compatible Regular Expressions – Spanish" lang="es" hreflang="es" data-title="Perl Compatible Regular Expressions" 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-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%D8%B9%D8%A8%D8%A7%D8%B1%D8%A7%D8%AA_%D8%A8%D8%A7%D9%82%D8%A7%D8%B9%D8%AF%D9%87_%D8%B3%D8%A7%D8%B2%DA%AF%D8%A7%D8%B1_%D8%A8%D8%A7_%D9%BE%D8%B1%D9%84" 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/PCRE" title="PCRE – French" lang="fr" hreflang="fr" data-title="PCRE" 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-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%ED%8E%84_%ED%98%B8%ED%99%98_%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-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions" title="Perl Compatible Regular Expressions – Japanese" lang="ja" hreflang="ja" data-title="Perl Compatible Regular Expressions" data-language-autonym="日本語" data-language-local-name="Japanese" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/PCRE" title="PCRE – Polish" lang="pl" hreflang="pl" data-title="PCRE" 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/Perl_Compatible_Regular_Expressions" title="Perl Compatible Regular Expressions – Portuguese" lang="pt" hreflang="pt" data-title="Perl Compatible Regular Expressions" 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-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/PCRE" title="PCRE – Russian" lang="ru" hreflang="ru" data-title="PCRE" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/PCRE" title="PCRE – Ukrainian" lang="uk" hreflang="uk" data-title="PCRE" data-language-autonym="Українська" data-language-local-name="Ukrainian" 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/Q125267#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/Perl_Compatible_Regular_Expressions" 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:Perl_Compatible_Regular_Expressions" 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/Perl_Compatible_Regular_Expressions"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&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=Perl_Compatible_Regular_Expressions&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/Perl_Compatible_Regular_Expressions"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&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=Perl_Compatible_Regular_Expressions&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/Perl_Compatible_Regular_Expressions" 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/Perl_Compatible_Regular_Expressions" 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=Perl_Compatible_Regular_Expressions&amp;oldid=1254397976" 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=Perl_Compatible_Regular_Expressions&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=Perl_Compatible_Regular_Expressions&amp;id=1254397976&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%2FPerl_Compatible_Regular_Expressions"><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%2FPerl_Compatible_Regular_Expressions"><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=Perl_Compatible_Regular_Expressions&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=Perl_Compatible_Regular_Expressions&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-wikibooks mw-list-item"><a href="https://en.wikibooks.org/wiki/Perl_Programming/Regular_expressions" hreflang="en"><span>Wikibooks</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/Q125267" 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"></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">Software library for interpreting regular expressions</div> <style data-mw-deduplicate="TemplateStyles:r1257001546">.mw-parser-output .infobox-subbox{padding:0;border:none;margin:-3px;width:auto;min-width:100%;font-size:100%;clear:none;float:none;background-color:transparent}.mw-parser-output .infobox-3cols-child{margin:auto}.mw-parser-output .infobox .navbar{font-size:100%}@media screen{html.skin-theme-clientpref-night .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .infobox-full-data:not(.notheme) div:not(.notheme){background:#1f1f23!important;color:#f8f9fa}}@media(min-width:640px){body.skin--responsive .mw-parser-output .infobox-table{display:table!important}body.skin--responsive .mw-parser-output .infobox-table>caption{display:table-caption!important}body.skin--responsive .mw-parser-output .infobox-table>tbody{display:table-row-group}body.skin--responsive .mw-parser-output .infobox-table tr{display:table-row!important}body.skin--responsive .mw-parser-output .infobox-table th,body.skin--responsive .mw-parser-output .infobox-table td{padding-left:inherit;padding-right:inherit}}</style><table class="infobox vevent"><caption class="infobox-title summary">Perl Compatible Regular Expressions</caption><tbody><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="/wiki/Programmer" title="Programmer">Original author(s)</a></th><td class="infobox-data"><a href="/wiki/Philip_Hazel" title="Philip Hazel">Philip Hazel</a></td></tr><tr style="display: none;"><td colspan="2" class="infobox-full-data"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1257001546"></td></tr><tr><th colspan="2" class="infobox-header"><a href="/wiki/Software_release_life_cycle" title="Software release life cycle">Stable release(s)</a></th></tr><tr><td colspan="2" class="infobox-full-data"><div style="margin:0px;"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1257001546"><table class="infobox-subbox"><tbody><tr><th scope="row" class="infobox-label">PCRE1</th><td class="infobox-data">8.45 / June&#160;15, 2021<span class="noprint">&#59;&#32;3 years ago</span><span style="display:none">&#160;(<span class="bday dtstart published updated">2021-06-15</span>)</span><sup id="cite_ref-PCRE1_1-0" class="reference"><a href="#cite_note-PCRE1-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup></td></tr><tr><th scope="row" class="infobox-label">PCRE2</th><td class="infobox-data">10.43 / February&#160;16, 2024<span class="noprint">&#59;&#32;9 months ago</span><span style="display:none">&#160;(<span class="bday dtstart published updated">2024-02-16</span>)</span><sup id="cite_ref-PCRE2_2-0" class="reference"><a href="#cite_note-PCRE2-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup></td></tr></tbody></table> </div></td></tr><tr style="display:none"><td colspan="2"> </td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="/wiki/Repository_(version_control)" title="Repository (version control)">Repository</a></th><td class="infobox-data"><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="plainlist"><ul><li><span class="url"><a rel="nofollow" class="external text" href="https://github.com/PCRE2Project/pcre2">github<wbr />.com<wbr />/PCRE2Project<wbr />/pcre2</a></span> <span class="mw-valign-text-top noprint" typeof="mw:File/Frameless"><a href="https://www.wikidata.org/wiki/Q125267#P1324" 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></li></ul> </div></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;">Written in</th><td class="infobox-data"><a href="/wiki/C_(programming_language)" title="C (programming language)">C</a></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="/wiki/Operating_system" title="Operating system">Operating system</a></th><td class="infobox-data"><a href="/wiki/Cross-platform" class="mw-redirect" title="Cross-platform">Cross-platform</a></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="/wiki/Software_categories#Categorization_approaches" title="Software categories">Type</a></th><td class="infobox-data"><a href="/wiki/Pattern_matching" title="Pattern matching">Pattern matching</a> <a href="/wiki/Library_(computing)" title="Library (computing)">library</a></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="/wiki/Software_license" title="Software license">License</a></th><td class="infobox-data"><a href="/wiki/BSD_licenses" title="BSD licenses">BSD</a></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;">Website</th><td class="infobox-data"><span class="url"><a rel="nofollow" class="external text" href="https://pcre.org/">pcre<wbr />.org</a></span> <span class="mw-valign-text-top noprint" typeof="mw:File/Frameless"><a href="https://www.wikidata.org/wiki/Q125267#P856" 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></td></tr></tbody></table> <p><b>Perl Compatible Regular Expressions</b> (<b>PCRE</b>) is a <a href="/wiki/Library_(computing)" title="Library (computing)">library</a> written in <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>, which implements a <a href="/wiki/Regular_expression" title="Regular expression">regular expression</a> engine, inspired by the capabilities of the <a href="/wiki/Perl" title="Perl">Perl programming language</a>. <a href="/wiki/Philip_Hazel" title="Philip Hazel">Philip Hazel</a> started writing PCRE in summer 1997.<sup id="cite_ref-073dda77f8b5f8fd09647bddbdfd70bf_3-0" class="reference"><a href="#cite_note-073dda77f8b5f8fd09647bddbdfd70bf-3"><span class="cite-bracket">&#91;</span>3<span class="cite-bracket">&#93;</span></a></sup> PCRE's syntax is much more powerful and flexible than either of the <a href="/wiki/Regular_expression#POSIX" title="Regular expression">POSIX regular expression</a> flavors (BRE, ERE)<sup id="cite_ref-e4ac0ff70c49a9478fa2d8c44bf2b644_4-0" class="reference"><a href="#cite_note-e4ac0ff70c49a9478fa2d8c44bf2b644-4"><span class="cite-bracket">&#91;</span>4<span class="cite-bracket">&#93;</span></a></sup> and than that of many other regular-expression libraries. </p><p>While PCRE originally aimed at feature-equivalence with Perl, the two implementations are not fully equivalent. During the PCRE 7.x and Perl 5.9.x phase, the two projects coordinated development, with features being ported between them in both directions.<sup id="cite_ref-48c79c744a1d99fc5e30e1e948afbd20_5-0" class="reference"><a href="#cite_note-48c79c744a1d99fc5e30e1e948afbd20-5"><span class="cite-bracket">&#91;</span>5<span class="cite-bracket">&#93;</span></a></sup> </p><p>In 2015, a fork of PCRE was released with a revised programming interface (API). The original software, now called PCRE1 (the 1.xx–8.xx series), has had bugs mended, but no further development. As of 2020<sup class="plainlinks noexcerpt noprint asof-tag update" style="display:none;"><a class="external text" href="https://en.wikipedia.org/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit">&#91;update&#93;</a></sup>, it is considered obsolete, and the current 8.45 release is likely to be the last. The new PCRE2 code (the 10.xx series) has had a number of extensions and coding improvements and is where development takes place. </p><p>A number of prominent <a href="/wiki/Open-source_software" title="Open-source software">open-source programs</a>, such as the <a href="/wiki/Apache_HTTP_Server" title="Apache HTTP Server">Apache</a> and <a href="/wiki/Nginx" title="Nginx">Nginx</a> HTTP servers, and the <a href="/wiki/PHP" title="PHP">PHP</a> and <a href="/wiki/R_(programming_language)" title="R (programming language)">R</a> scripting languages, incorporate the PCRE library; proprietary software can do likewise, as the library is BSD-licensed. As of Perl 5.10, PCRE is also available as a replacement for Perl's default regular-expression engine through the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">re::engine::PCRE</code> module. </p><p>The library can be built on Unix, Windows, and several other environments. PCRE2 is distributed with a POSIX C wrapper,<sup id="cite_ref-76a22ecb95777e7af2a48518dfc5debd_6-0" class="reference"><a href="#cite_note-76a22ecb95777e7af2a48518dfc5debd-6"><span class="cite-bracket">&#91;</span>Note 1<span class="cite-bracket">&#93;</span></a></sup> several test programs, and the utility program <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">pcregrep</code>/<code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">pcre2grep</code> that is built in tandem with the library. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Features">Features</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=1" title="Edit section: Features"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Just-in-time_compiler_support">Just-in-time compiler support</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=2" title="Edit section: Just-in-time compiler support"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The <a href="/wiki/Just-in-time_compiler" class="mw-redirect" title="Just-in-time compiler">just-in-time compiler</a> can be enabled when the PCRE2 library is built. Large performance benefits are possible when (for example) the calling program utilizes the feature with compatible patterns that are executed repeatedly. The just-in-time compiler support was written by Zoltan Herczeg and is not addressed in the POSIX wrapper. </p> <div class="mw-heading mw-heading3"><h3 id="Flexible_memory_management">Flexible memory management</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=3" title="Edit section: Flexible memory management"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The use of the system stack for backtracking can be problematic in PCRE1, which is why this feature of the implementation was changed in PCRE2. The heap is now used for this purpose, and the total amount can be limited. The problem of <a href="/wiki/Stack_overflow" title="Stack overflow">stack overflow</a>, which came up regularly with PCRE1, is no longer an issue with PCRE2 from release 10.30 (2017). </p> <div class="mw-heading mw-heading3"><h3 id="Consistent_escaping_rules">Consistent escaping rules</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=4" title="Edit section: Consistent escaping rules"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Like Perl, PCRE2 has consistent escaping rules: any non-alpha-numeric character may be escaped to mean its literal value by prefixing a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\</code> (backslash) before the character. Any alpha-numeric character preceded by a backslash typically gives it a special meaning. In the case where the sequence has not been defined to be special, an error occurs. This is different to Perl, which gives an error only if it is in warning mode (PCRE2 does not have a warning mode). In basic POSIX regular expressions, sometimes backslashes escaped non-alpha-numerics (e.g. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\.</code>), and sometimes they introduced a special feature (e.g. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\(\)</code>). </p> <div class="mw-heading mw-heading3"><h3 id="Extended_character_classes">Extended character classes</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=5" title="Edit section: Extended character classes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Single-letter <a href="/wiki/Regular_expression#Character_classes" title="Regular expression">character classes</a> are supported in addition to the longer POSIX names. For example, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\d</code> matches any digit exactly as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">[[:digit:]]</code> would in POSIX regular expressions. </p> <div class="mw-heading mw-heading3"><h3 id="Minimal_matching_(a.k.a._&quot;ungreedy&quot;)"><span id="Minimal_matching_.28a.k.a._.22ungreedy.22.29"></span>Minimal matching (a.k.a. "ungreedy")</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=6" title="Edit section: Minimal matching (a.k.a. &quot;ungreedy&quot;)"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">?</code> may be placed after any repetition quantifier to indicate that the shortest match should be used. The default is to attempt the <a href="/wiki/Maximal_munch" title="Maximal munch">longest match</a> first and backtrack through shorter matches: e.g. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">a.*?b</code> would match first "ab" in "ababab", where <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">a.*b</code> would match the entire string. </p><p>If the <code>U</code> flag is set, then quantifiers are ungreedy (lazy) by default, while <code>?</code> makes them greedy. </p> <div class="mw-heading mw-heading3"><h3 id="Unicode_character_properties">Unicode character properties</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=7" title="Edit section: Unicode character properties"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Unicode" title="Unicode">Unicode</a> defines several properties for each character. Patterns in PCRE2 can match these properties: e.g. <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">Ps</span><span class="p">}</span><span class="o">.*?</span><span class="err">\</span><span class="nv">p</span><span class="p">{</span><span class="x">Pe</span><span class="p">}</span></code> would match a string beginning with any "opening punctuation" and ending with any "close punctuation" such as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">[abc]</code>. Matching of certain "normal" metacharacters can be driven by Unicode properties when the compile option PCRE2_UCP is set. The option can be set for a pattern by including <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*UCP)</code> at the start of pattern. The option alters behavior of the following metacharacters: <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\B</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\b</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\D</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\d</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\S</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\s</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\W</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\w</code>, and some of the POSIX character classes. For example, the set of characters matched by <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\w</code> (word characters) is expanded to include letters and accented letters as defined by Unicode properties. Such matching is slower than the normal (<a href="/wiki/ASCII" title="ASCII">ASCII</a>-only) non-UCP alternative. Note that the UCP option requires the library to have been built to include Unicode support (this is the default for PCRE2). Very early versions of PCRE1 supported only ASCII code. Later, UTF-8 support was added. Support for UTF-16 was added in version 8.30, and support for UTF-32 in version 8.32. PCRE2 has always supported all three UTF encodings. </p> <div class="mw-heading mw-heading3"><h3 id="Multiline_matching">Multiline matching</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=8" title="Edit section: Multiline matching"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">^</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">$</code> can match at the beginning and end of a string only, or at the start and end of each "line" within the string, depending on what options are set. </p> <div class="mw-heading mw-heading3"><h3 id="Newline/linebreak_options"><span id="Newline.2Flinebreak_options"></span>Newline/linebreak options</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=9" title="Edit section: Newline/linebreak options"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>When PCRE is compiled, a newline default is selected. Which newline/linebreak is in effect affects where PCRE detects <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">^</code> line beginnings and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">$</code> ends (in multiline mode), as well as what matches dot (regardless of multiline mode, unless the dotall option <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?s)</code> is set). It also affects PCRE matching procedure (since version 7.0): when an unanchored pattern fails to match at the start of a newline sequence, PCRE advances past the entire newline sequence before retrying the match. If the newline option alternative in effect includes CRLF as one of the valid linebreaks, it does not skip the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\n</code> in a CRLF if the pattern contains specific <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\r</code> or <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\n</code> references (since version 7.3). Since version 8.10, the metacharacter <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\N</code> always matches any character other than linebreak characters. It has the same behavior as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">.</code> when the dotall option aka <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?s)</code> is not in effect. </p><p>The newline option can be altered with external options when PCRE is compiled and when it is run. Some applications using PCRE provide users with the means to apply this setting through an external option. So the newline option can also be stated at the start of the pattern using one of the following: </p> <ul><li><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*LF)</code> Newline is a linefeed character. Corresponding linebreaks can be matched with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\n</code>.</li> <li><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*CR)</code> Newline is a carriage return. Corresponding linebreaks can be matched with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\r</code>.</li> <li><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*CRLF)</code> Newline/linebreak is a carriage return followed by a linefeed. Corresponding linebreaks can be matched with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\r\n</code>.</li> <li><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*ANYCRLF)</code> Any of the above encountered in the data will trigger newline processing. Corresponding linebreaks can be matched with <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="o">(?:</span><span class="err">\</span><span class="nv">r</span><span class="err">\</span><span class="nv">n</span><span class="o">?|</span><span class="err">\</span><span class="nv">n</span><span class="o">)</span></code> or with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\R</code>. See below for configuration and options concerning what matches backslash-R.</li> <li><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*ANY)</code> Any of the above plus special Unicode linebreaks.</li></ul> <p>When not in UTF-8 mode, corresponding linebreaks can be matched with <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="o">(?:</span><span class="err">\</span><span class="nv">r</span><span class="err">\</span><span class="nv">n</span><span class="o">?|</span><span class="err">\</span><span class="nv">n</span><span class="o">|</span><span class="err">\</span><span class="nv">x0B</span><span class="o">|</span><span class="err">\</span><span class="nv">f</span><span class="o">|</span><span class="err">\</span><span class="nv">x85</span><span class="o">)</span></code><sup id="cite_ref-bace6b9cc26fa4b3ba98e0869ed4f3fa_7-0" class="reference"><a href="#cite_note-bace6b9cc26fa4b3ba98e0869ed4f3fa-7"><span class="cite-bracket">&#91;</span>Note 2<span class="cite-bracket">&#93;</span></a></sup> or <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\R</code>. </p><p>In UTF-8 mode, two additional characters are recognized as line breaks with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*ANY)</code>: </p> <ul><li>LS (line separator, U+2028),</li> <li>PS (paragraph separator, U+2029).</li></ul> <p>On Windows, in non-Unicode data, some of the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">ANY</code> linebreak characters have other meanings. </p><p>For example, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\x85</code> can match a horizontal ellipsis, and if encountered while the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">ANY</code> newline is in effect, it would trigger newline processing. </p><p>See below for configuration and options concerning what matches backslash-R. </p> <div class="mw-heading mw-heading3"><h3 id="Backslash-R_options">Backslash-R options</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=10" title="Edit section: Backslash-R options"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>When PCRE is compiled, a default is selected for what matches <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\R</code>. The default can be either to match the linebreaks corresponding to ANYCRLF or those corresponding to ANY. The default can be overridden when necessary by including <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*BSR_UNICODE)</code> or <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*BSR_ANYCRLF)</code> at the start of the pattern. A <code>(*<i>newline</i>)</code> option can be provided in addition to a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*BSR..)</code> option, e.g., <code>(*BSR_UNICODE)(*ANY)<i>rest-of-pattern</i></code>. The backslash-R options also can be changed with external options by the application calling PCRE2, when a pattern is compiled. </p> <div class="mw-heading mw-heading3"><h3 id="Beginning_of_pattern_options">Beginning of pattern options</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=11" title="Edit section: Beginning of pattern options"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Linebreak options such as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*LF)</code> documented above; backslash-R options such as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*BSR_ANYCRLF)</code> documented above; Unicode Character Properties option <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*UCP)</code> documented above; <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*UTF8)</code> option documented as follows: if PCRE2 has been compiled with <a href="/wiki/Unicode_Transformation_Format" class="mw-redirect" title="Unicode Transformation Format">UTF</a> support, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*UTF)</code> option at the beginning of a pattern can be used instead of setting an external option to invoke UTF-8, UTF-16, or UTF-32 mode. </p> <div class="mw-heading mw-heading3"><h3 id="Backreferences">Backreferences</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=12" title="Edit section: Backreferences"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A pattern may refer back to the results of a previous match. For example, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(a|b)c\1</code> would match either "aca" or "bcb" and would not match, for example, "acb". </p> <div class="mw-heading mw-heading3"><h3 id="Named_subpatterns">Named subpatterns</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=13" title="Edit section: Named subpatterns"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A sub-pattern (surrounded by parentheses, like <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(...)</code>) may be named by including a leading <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">?P&lt;name&gt;</code> after the opening parenthesis. Named subpatterns are a feature that PCRE adopted from <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a> regular expressions. </p><p>This feature was subsequently adopted by Perl, so now named groups can also be defined using <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?&lt;name&gt;...)</code> or <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?&#39;name&#39;...)</code>, as well as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?P&lt;name&gt;...)</code>. Named groups can be backreferenced with, for example: <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?P=name)</code> (Python syntax) or <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\k&#39;name&#39;</code> (Perl syntax). </p> <div class="mw-heading mw-heading3"><h3 id="Subroutines">Subroutines</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=14" title="Edit section: Subroutines"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>While a backreference provides a mechanism to refer to that part of the subject that has previously matched a subpattern, a subroutine provides a mechanism to reuse an underlying previously defined subpattern. The subpattern's options, such as case independence, are fixed when the subpattern is defined. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(a.c)(?1)</code> would match "aacabc" or "abcadc", whereas using a backreference <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(a.c)\1</code> would not, though both would match "aacaac" or "abcabc". PCRE also supports a non-Perl <a href="/wiki/Oniguruma" title="Oniguruma">Oniguruma</a> construct for subroutines. They are specified using <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\g&lt;subpat-number&gt;</code> or <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\g&lt;subpat-name&gt;</code>. </p> <div class="mw-heading mw-heading3"><h3 id="Atomic_grouping">Atomic grouping</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=15" title="Edit section: Atomic grouping"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Atomic grouping is a way of preventing <a href="/wiki/Backtracking" title="Backtracking">backtracking</a> in a pattern. For example, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">a++bc</code> will match as many "a"s as possible and never back up to try one less. </p> <div class="mw-heading mw-heading3"><h3 id="Look-ahead_and_look-behind_assertions">Look-ahead and look-behind assertions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=16" title="Edit section: Look-ahead and look-behind 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%;font-family:monospace;">(?<b>&lt;=</b><span style="background:black;color:white;font-size:80%;padding:0 0.5ex;border-radius:2ex;">pattern</span>) </td> <td style="text-align:center;font-size:125%;font-family:monospace;">(?<b>=</b><span style="background:black;color:white;font-size:80%;padding:0 0.5ex;border-radius:2ex;">pattern</span>) </td></tr> <tr> <th>Negative </th> <td style="text-align:center;font-size:125%;font-family:monospace;">(?<b>&lt;!</b><span style="background:black;color:white;font-size:80%;padding:0 0.5ex;border-radius:2ex;">pattern</span>) </td> <td style="text-align:center;font-size:125%;font-family:monospace;">(?<span style="padding:1px;"><b>!</b></span><span style="background:black;color:white;font-size:80%;padding:0 0.5ex;border-radius:2ex;">pattern</span>) </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>Patterns may assert that previous text or subsequent text contains a pattern without consuming matched text (zero-width assertion). For example, /<code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\w+(?=\t)</code>/ matches a word followed by a <a href="/wiki/Tab_key#Tab_characters" title="Tab key">tab</a>, without including the tab itself. </p><p>Look-behind assertions cannot be of uncertain length though (unlike Perl) each branch can be a different fixed length. </p><p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\K</code> can be used in a pattern to reset the start of the current whole match. This provides a flexible alternative approach to look-behind assertions because the discarded part of the match (the part that precedes <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\K</code>) need not be fixed in length. </p> <div class="mw-heading mw-heading3"><h3 id="Escape_sequences_for_zero-width_assertions">Escape sequences for zero-width assertions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=17" title="Edit section: Escape sequences for zero-width assertions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>E.g. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\b</code> for matching zero-width "word boundaries", similar to <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>. </p> <div class="mw-heading mw-heading3"><h3 id="Comments">Comments</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=18" title="Edit section: Comments"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A comment begins with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?#</code> and ends at the next closing parenthesis. </p> <div class="mw-heading mw-heading3"><h3 id="Recursive_patterns">Recursive patterns</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=19" title="Edit section: Recursive patterns"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A pattern can refer back to itself recursively or to any subpattern. For example, the pattern <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="o">((</span><span class="nv">a</span><span class="o">*|(?</span><span class="nv">R</span><span class="o">))*</span><span class="err">\</span><span class="o">)</span></code> will match any combination of balanced parentheses and "a"s. </p> <div class="mw-heading mw-heading3"><h3 id="Generic_callouts">Generic callouts</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=20" title="Edit section: Generic callouts"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>PCRE expressions can embed <code>(?C<i>n</i>)</code>, where <i>n</i> is some number. This will call out to an external user-defined function through the PCRE API and can be used to embed arbitrary code in a pattern. </p> <div class="mw-heading mw-heading2"><h2 id="Differences_from_Perl">Differences from Perl</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=21" title="Edit section: Differences from Perl"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1251242444">.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}</style><table class="box-Update plainlinks metadata ambox ambox-content ambox-Update" role="presentation"><tbody><tr><td class="mbox-image"><div class="mbox-image-div"><span typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/9/98/Ambox_current_red.svg/42px-Ambox_current_red.svg.png" decoding="async" width="42" height="34" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/9/98/Ambox_current_red.svg/63px-Ambox_current_red.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/9/98/Ambox_current_red.svg/84px-Ambox_current_red.svg.png 2x" data-file-width="360" data-file-height="290" /></span></span></div></td><td class="mbox-text"><div class="mbox-text-span">This section needs to be <b>updated</b>. The reason given is: the reference given below refers to Perl 5.26.<span class="hide-when-compact"> Please help update this article to reflect recent events or newly available information.</span> <span class="date-container"><i>(<span class="date">September 2020</span>)</i></span></div></td></tr></tbody></table> <p>Differences between PCRE2 and Perl (as of Perl 5.9.4) include but are not limited to:<sup id="cite_ref-d4b1d6e7da15cd67a02350d2bcc49fb7_8-0" class="reference"><a href="#cite_note-d4b1d6e7da15cd67a02350d2bcc49fb7-8"><span class="cite-bracket">&#91;</span>6<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Until_release_10.30_recursive_matches_were_atomic_in_PCRE_and_non_atomic_in_Perl">Until release 10.30 recursive matches were atomic in PCRE and non atomic in Perl</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=22" title="Edit section: Until release 10.30 recursive matches were atomic in PCRE and non atomic in Perl"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>This meant that <code class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><span class="s">&quot;&lt;&lt;!&gt;!&gt;!&gt;&gt;&lt;&gt;&gt;!&gt;!&gt;!&gt;&quot;</span><span class="w"> </span><span class="o">=~</span><span class="sr"> /^(&lt;(?:[^&lt;&gt;]+|(?3)|(?1))*&gt;)()(!&gt;!&gt;!&gt;)$/</span></code> would match in Perl but not in PCRE2 until release 10.30. </p> <div class="mw-heading mw-heading3"><h3 id="The_value_of_a_capture_buffer_deriving_from_the_?_quantifier_(match_1_or_0_times)_when_nested_in_another_quantified_capture_buffer_is_different"><span id="The_value_of_a_capture_buffer_deriving_from_the_.3F_quantifier_.28match_1_or_0_times.29_when_nested_in_another_quantified_capture_buffer_is_different"></span>The value of a capture buffer deriving from the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">?</code> quantifier (match 1 or 0 times) when nested in another quantified capture buffer is different</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=23" title="Edit section: The value of a capture buffer deriving from the ? quantifier (match 1 or 0 times) when nested in another quantified capture buffer is different"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In Perl <code class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><span class="s">&quot;aba&quot;</span><span class="w"> </span><span class="o">=~</span><span class="sr"> /^(a(b)?)+$/</span><span class="p">;</span></code> will result in <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">$1</code> containing "a" and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">$2</code> containing <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">undef</code>, but in PCRE will result in <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">$2</code> containing "b". </p> <div class="mw-heading mw-heading3"><h3 id="PCRE_allows_named_capture_buffers_to_be_given_numeric_names;_Perl_requires_the_name_to_follow_the_rule_of_barewords"><span id="PCRE_allows_named_capture_buffers_to_be_given_numeric_names.3B_Perl_requires_the_name_to_follow_the_rule_of_barewords"></span>PCRE allows named capture buffers to be given numeric names; Perl requires the name to follow the rule of barewords</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=24" title="Edit section: PCRE allows named capture buffers to be given numeric names; Perl requires the name to follow the rule of barewords"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>This means that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">\g{}</code> is unambiguous in Perl, but potentially ambiguous in PCRE. </p><p>This is no longer a difference since PCRE 8.34 (released on 2013-12-15), which no longer allows group names to start with a digit.<sup id="cite_ref-5237b7677dd1da0360e7942ee2de56a6_9-0" class="reference"><a href="#cite_note-5237b7677dd1da0360e7942ee2de56a6-9"><span class="cite-bracket">&#91;</span>7<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="PCRE_allows_alternatives_within_lookbehind_to_be_different_lengths">PCRE allows alternatives within lookbehind to be different lengths</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=25" title="Edit section: PCRE allows alternatives within lookbehind to be different lengths"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Within lookbehind assertions, both PCRE and Perl require fixed-length patterns. </p><p>That is, both PCRE and Perl disallow variable-length patterns using quantifiers within lookbehind assertions. </p><p>However, Perl requires all alternative branches of a lookbehind assertion to be the same length as each other, whereas PCRE allows those alternative branches to have different lengths from each other as long as each branch still has a fixed length. </p> <div class="mw-heading mw-heading3"><h3 id="PCRE_does_not_support_certain_&quot;experimental&quot;_Perl_constructs"><span id="PCRE_does_not_support_certain_.22experimental.22_Perl_constructs"></span>PCRE does not support certain "experimental" Perl constructs</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=26" title="Edit section: PCRE does not support certain &quot;experimental&quot; Perl constructs"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Such as <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(??{...})</code> (a callback whose return is evaluated as being part of the pattern) nor the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?{})</code> construct, although the latter can be emulated using <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?Cn)</code>. </p><p>Recursion control verbs added in the Perl 5.9.x series are also not supported. </p><p>Support for experimental backtracking control verbs (added in Perl 5.10) is available in PCRE since version 7.3. </p><p>They are <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*FAIL)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*F)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*PRUNE)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*SKIP)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*THEN)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*COMMIT)</code>, and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*ACCEPT)</code>. </p><p>Perl's corresponding use of arguments with backtracking control verbs is not generally supported. </p><p>Note however that since version 8.10, PCRE supports the following verbs with a specified argument: <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*MARK:markName)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*SKIP:markName)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*PRUNE:markName)</code>, and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*THEN:markName)</code>. </p><p>Since version 10.32 PCRE2 has supported <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*ACCEPT:markName)</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*FAIL:markName)</code>, and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(*COMMIT:markName)</code>. </p> <div class="mw-heading mw-heading3"><h3 id="PCRE_and_Perl_are_slightly_different_in_their_tolerance_of_erroneous_constructs">PCRE and Perl are slightly different in their tolerance of erroneous constructs</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=27" title="Edit section: PCRE and Perl are slightly different in their tolerance of erroneous constructs"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Perl allows quantifiers on the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">(?!...)</code> construct, which is meaningless but harmless (albeit inefficient); PCRE produces an error in versions before 8.13. </p> <div class="mw-heading mw-heading3"><h3 id="PCRE_has_a_hard_limit_on_recursion_depth,_Perl_does_not"><span id="PCRE_has_a_hard_limit_on_recursion_depth.2C_Perl_does_not"></span>PCRE has a hard limit on recursion depth, Perl does not</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=28" title="Edit section: PCRE has a hard limit on recursion depth, Perl does not"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>With default build options <code class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><span class="s">&quot;bbbbXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&quot;</span><span class="w"> </span><span class="o">=~</span><span class="sr"> /.X(.+)+X/</span></code> will fail to match due to the limit, but Perl will match this correctly. </p><p>Perl uses the heap for recursion and has no hard limit for recursion depth, whereas PCRE2 has a compile-time default limit that can be adjusted up or down by the calling application. </p> <div class="mw-heading mw-heading3"><h3 id="Verification">Verification</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=29" title="Edit section: Verification"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>With the exception of the above points, PCRE is capable of passing the tests in the Perl "<code>t/op/re_tests</code>" file, one of the main syntax-level regression tests for Perl's regular expression engine. </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=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=30" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1259569809">.mw-parser-output .portalbox{padding:0;margin:0.5em 0;display:table;box-sizing:border-box;max-width:175px;list-style:none}.mw-parser-output .portalborder{border:1px solid var(--border-color-base,#a2a9b1);padding:0.1em;background:var(--background-color-neutral-subtle,#f8f9fa)}.mw-parser-output .portalbox-entry{display:table-row;font-size:85%;line-height:110%;height:1.9em;font-style:italic;font-weight:bold}.mw-parser-output .portalbox-image{display:table-cell;padding:0.2em;vertical-align:middle;text-align:center}.mw-parser-output .portalbox-link{display:table-cell;padding:0.2em 0.2em 0.2em 0.3em;vertical-align:middle}@media(min-width:720px){.mw-parser-output .portalleft{clear:left;float:left;margin:0.5em 1em 0.5em 0}.mw-parser-output .portalright{clear:right;float:right;margin:0.5em 0 0.5em 1em}}</style><ul role="navigation" aria-label="Portals" class="noprint portalbox portalborder portalright"> <li class="portalbox-entry"><span class="portalbox-image"><span class="noviewer" typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/31/Free_and_open-source_software_logo_%282009%29.svg/28px-Free_and_open-source_software_logo_%282009%29.svg.png" decoding="async" width="28" height="28" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/31/Free_and_open-source_software_logo_%282009%29.svg/42px-Free_and_open-source_software_logo_%282009%29.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/3/31/Free_and_open-source_software_logo_%282009%29.svg/56px-Free_and_open-source_software_logo_%282009%29.svg.png 2x" data-file-width="512" data-file-height="512" /></span></span></span><span class="portalbox-link"><a href="/wiki/Portal:Free_and_open-source_software" title="Portal:Free and open-source software">Free and open-source software portal</a></span></li></ul> <ul><li><a href="/wiki/Grep#pcregrep" title="Grep"><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">pcregrep</code></a></li> <li><a href="/wiki/Comparison_of_regular_expression_engines" title="Comparison of regular expression engines">Comparison of regular expression engines</a></li></ul> <div class="mw-heading mw-heading2"><h2 id="Notes_and_references">Notes and references</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=31" title="Edit section: Notes and references"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Notes">Notes</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=32" title="Edit section: Notes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-76a22ecb95777e7af2a48518dfc5debd-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-76a22ecb95777e7af2a48518dfc5debd_6-0">^</a></b></span> <span class="reference-text">The core PCRE2 library provides both matching and match and replace functionality.</span> </li> <li id="cite_note-bace6b9cc26fa4b3ba98e0869ed4f3fa-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-bace6b9cc26fa4b3ba98e0869ed4f3fa_7-0">^</a></b></span> <span class="reference-text">Sure the <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">x85</span></code> part is not <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">xC2</span><span class="err">\</span><span class="nv">x85</span></code>? (i.e. <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="o">(?:</span><span class="err">\</span><span class="nv">r</span><span class="err">\</span><span class="nv">n</span><span class="o">?|</span><span class="err">\</span><span class="nv">n</span><span class="o">|</span><span class="err">\</span><span class="nv">x0B</span><span class="o">|</span><span class="err">\</span><span class="nv">f</span><span class="o">|</span><span class="err">\</span><span class="nv">xC2</span><span class="err">\</span><span class="nv">x85</span><span class="o">)</span></code>, as <a href="/wiki/List_of_Unicode_characters#Control_codes" title="List of Unicode characters">U+0085</a>&#160;!= 0x85)<br /><br /> <b>Caveat</b>: If the pattern <code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">xC2</span><span class="err">\</span><span class="nv">x85</span></code> failed to work: experiment with the RegEx implementation's Unicode settings, or try substituting with the following: <ul><li><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">x</span><span class="p">{</span><span class="x">0085</span><span class="p">}</span></code></li> <li><code class="mw-highlight mw-highlight-lang-ragel mw-content-ltr" dir="ltr"><span class="err">\</span><span class="nv">u0085</span></code></li></ul> </span></li> </ol></div> <div class="mw-heading mw-heading3"><h3 id="References">References</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=33" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div style="display:none"> <p> <sup id="cite_ref-5b0d0a30d96a4e793b9c2266c338db05_10-0" class="reference"><a href="#cite_note-5b0d0a30d96a4e793b9c2266c338db05-10"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup> </p> </div> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-PCRE1-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-PCRE1_1-0">^</a></b></span> <span class="reference-text"> Final release of PCRE1: <a rel="nofollow" class="external free" href="https://lists.exim.org/lurker/message/20210615.162400.c16ff8a3.en.html">https://lists.exim.org/lurker/message/20210615.162400.c16ff8a3.en.html</a></span> </li> <li id="cite_note-PCRE2-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-PCRE2_2-0">^</a></b></span> <span class="reference-text"> Releases: <a rel="nofollow" class="external free" href="https://github.com/PCRE2Project/pcre2/releases">https://github.com/PCRE2Project/pcre2/releases</a></span> </li> <li id="cite_note-073dda77f8b5f8fd09647bddbdfd70bf-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-073dda77f8b5f8fd09647bddbdfd70bf_3-0">^</a></b></span> <span class="reference-text"> Exim and PCRE: How free software hijacked my life (1999-12), by <a href="/wiki/Philip_Hazel" title="Philip Hazel">Philip Hazel</a>, p. 7: <a rel="nofollow" class="external free" href="https://www.ukuug.org/events/winter99/proc/PH.ps">https://www.ukuug.org/events/winter99/proc/PH.ps</a> <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><b>What about PCRE?</b> </p><ul><li>Written summer 1997, placed on ftp site.</li> <li>People found it, and started a mailing list.</li> <li>There has been a trickle of enhancements.</li></ul></blockquote></span></li> <li id="cite_note-e4ac0ff70c49a9478fa2d8c44bf2b644-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-e4ac0ff70c49a9478fa2d8c44bf2b644_4-0">^</a></b></span> <span class="reference-text"> <ul><li>Regular Expression - POSIX Standard (Google Search): <a rel="nofollow" class="external free" href="https://www.google.com/search?num=100&amp;q=%22Regular+Expression%22%7C%22Regular+Expressions%22%7C%22RegEx%22%7C%22RegExp%22+site%3Apubs.opengroup.org+inurl%3Aonlinepubs%2F9699919799+-intitle%3A%22Index+of+%2Fonlinepubs%22+-inurl%3Aidx+-inurl%3Acontents.html+-inurl%3Atoc.html+-inurl%3A9699919799.orig+-inurl%3A2008edition+-inurl%3A2013edition+-inurl%3A2016edition+-inurl%3A2018edition">https://www.google.com/search?num=100&amp;q=%22Regular+Expression%22%7C%22Regular+Expressions%22%7C%22RegEx%22%7C%22RegExp%22+site%3Apubs.opengroup.org+inurl%3Aonlinepubs%2F9699919799+-intitle%3A%22Index+of+%2Fonlinepubs%22+-inurl%3Aidx+-inurl%3Acontents.html+-inurl%3Atoc.html+-inurl%3A9699919799.orig+-inurl%3A2008edition+-inurl%3A2013edition+-inurl%3A2016edition+-inurl%3A2018edition</a></li> <li>Utilities § Pattern Matching Notation: <a rel="nofollow" class="external free" href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html#tag_18_13">https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html#tag_18_13</a></li> <li>Base Definitions § Basic Regular Expressions: <a rel="nofollow" class="external free" href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/V1_chap09.html#tag_09_03">https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/V1_chap09.html#tag_09_03</a></li> <li>Rationale § Regular Expressions: <a rel="nofollow" class="external free" href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/xrat/V4_xbd_chap09.html#tag_21_09">https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/xrat/V4_xbd_chap09.html#tag_21_09</a></li></ul> </span></li> <li id="cite_note-48c79c744a1d99fc5e30e1e948afbd20-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-48c79c744a1d99fc5e30e1e948afbd20_5-0">^</a></b></span> <span class="reference-text"> PCRE2 - Perl-compatible regular expressions (revised API) (2020), by <a href="/wiki/University_of_Cambridge" title="University of Cambridge">University of Cambridge</a>: <a rel="nofollow" class="external free" href="https://pcre.org/pcre2.txt">https://pcre.org/pcre2.txt</a></span> </li> <li id="cite_note-d4b1d6e7da15cd67a02350d2bcc49fb7-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-d4b1d6e7da15cd67a02350d2bcc49fb7_8-0">^</a></b></span> <span class="reference-text"> Differences Between PCRE2 and Perl (2019-07-13), by <a href="/wiki/Philip_Hazel" title="Philip Hazel">Philip Hazel</a>: <a rel="nofollow" class="external free" href="https://www.pcre.org/current/doc/html/pcre2compat.html">https://www.pcre.org/current/doc/html/pcre2compat.html</a></span> </li> <li id="cite_note-5237b7677dd1da0360e7942ee2de56a6-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-5237b7677dd1da0360e7942ee2de56a6_9-0">^</a></b></span> <span class="reference-text"> Quote PCRE changelog (<a rel="nofollow" class="external free" href="https://www.pcre.org/original/changelog.txt">https://www.pcre.org/original/changelog.txt</a>): "Perl no longer allows group names to start with digits, so I have made this change also in PCRE."</span> </li> <li id="cite_note-5b0d0a30d96a4e793b9c2266c338db05-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-5b0d0a30d96a4e793b9c2266c338db05_10-0">^</a></b></span> <span class="reference-text"> ChangeLog for PCRE2: <a rel="nofollow" class="external free" href="https://www.pcre.org/changelog.txt">https://www.pcre.org/changelog.txt</a></span> </li> </ol></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=Perl_Compatible_Regular_Expressions&amp;action=edit&amp;section=34" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><span class="official-website"><span class="url"><a rel="nofollow" class="external text" href="https://pcre.org/">Official website</a></span></span> <span class="mw-valign-text-top" typeof="mw:File/Frameless"><a href="https://www.wikidata.org/wiki/Q125267#P856" 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></li> <li>PCRE - Development mailing list: <a rel="nofollow" class="external free" href="https://groups.google.com/g/pcre2-dev">https://groups.google.com/g/pcre2-dev</a></li> <li>PCRE - Bug Tracker: <a rel="nofollow" class="external free" href="https://github.com/PCRE2Project/pcre2/issues">https://github.com/PCRE2Project/pcre2/issues</a></li> <li>Pattern Matching Using Regular Expressions (2010-03-02), by Nick Maclaren, Philip Hazel: <a rel="nofollow" class="external free" href="https://www-uxsup.csx.cam.ac.uk/courses/moved.REs/paper.pdf">https://www-uxsup.csx.cam.ac.uk/courses/moved.REs/paper.pdf</a></li> <li>pcre 8.43 (2019-04) - Windows Cygwin x86-64: <a rel="nofollow" class="external free" href="https://www-uxsup.csx.cam.ac.uk/pub/windows/cygwin/x86_64/release/pcre/">https://www-uxsup.csx.cam.ac.uk/pub/windows/cygwin/x86_64/release/pcre/</a></li></ul> <!-- NewPP limit report Parsed by mw‐web.codfw.main‐847495b4dd‐psqvd Cached time: 20241128121734 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.467 seconds Real time usage: 3.404 seconds Preprocessor visited node count: 2497/1000000 Post‐expand include size: 30707/2097152 bytes Template argument size: 7196/2097152 bytes Highest expansion depth: 25/100 Expensive parser function count: 117/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 28225/5000000 bytes Lua time usage: 0.162/10.000 seconds Lua memory usage: 3365494/52428800 bytes Number of Wikibase entities loaded: 1/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 3346.278 1 -total 6.72% 224.731 2 Template:Infobox 6.64% 222.162 1 Template:Infobox_software 2.84% 94.930 1 Template:Short_description 2.70% 90.336 10 Template:Main_other 2.20% 73.528 1 Template:Update 2.11% 70.449 1 Template:Infobox_software/stacked 2.01% 67.172 1 Template:Ambox 1.77% 59.313 2 Template:Pagetype 1.70% 56.931 1 Template:Multiple_releases --> <!-- Saved in parser cache with key enwiki:pcache:idhash:1712290-0!canonical and timestamp 20241128121734 and revision id 1254397976. 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=Perl_Compatible_Regular_Expressions&amp;oldid=1254397976">https://en.wikipedia.org/w/index.php?title=Perl_Compatible_Regular_Expressions&amp;oldid=1254397976</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:Pattern_matching" title="Category:Pattern matching">Pattern matching</a></li><li><a href="/wiki/Category:C_(programming_language)_libraries" title="Category:C (programming language) libraries">C (programming language) libraries</a></li><li><a href="/wiki/Category:Perl" title="Category:Perl">Perl</a></li><li><a href="/wiki/Category:Regular_expressions" title="Category:Regular expressions">Regular expressions</a></li><li><a href="/wiki/Category:Software_using_the_BSD_license" title="Category:Software using the BSD license">Software using the BSD license</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: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:Articles_containing_potentially_dated_statements_from_2020" title="Category:Articles containing potentially dated statements from 2020">Articles containing potentially dated statements from 2020</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:Wikipedia_articles_in_need_of_updating_from_September_2020" title="Category:Wikipedia articles in need of updating from September 2020">Wikipedia articles in need of updating from September 2020</a></li><li><a href="/wiki/Category:All_Wikipedia_articles_in_need_of_updating" title="Category:All Wikipedia articles in need of updating">All Wikipedia articles in need of updating</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 30 October 2024, at 20:27<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=Perl_Compatible_Regular_Expressions&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-59bbd5969d-qfcfc","wgBackendResponseTime":171,"wgPageParseReport":{"limitreport":{"cputime":"0.467","walltime":"3.404","ppvisitednodes":{"value":2497,"limit":1000000},"postexpandincludesize":{"value":30707,"limit":2097152},"templateargumentsize":{"value":7196,"limit":2097152},"expansiondepth":{"value":25,"limit":100},"expensivefunctioncount":{"value":117,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":28225,"limit":5000000},"entityaccesscount":{"value":1,"limit":400},"timingprofile":["100.00% 3346.278 1 -total"," 6.72% 224.731 2 Template:Infobox"," 6.64% 222.162 1 Template:Infobox_software"," 2.84% 94.930 1 Template:Short_description"," 2.70% 90.336 10 Template:Main_other"," 2.20% 73.528 1 Template:Update"," 2.11% 70.449 1 Template:Infobox_software/stacked"," 2.01% 67.172 1 Template:Ambox"," 1.77% 59.313 2 Template:Pagetype"," 1.70% 56.931 1 Template:Multiple_releases"]},"scribunto":{"limitreport-timeusage":{"value":"0.162","limit":"10.000"},"limitreport-memusage":{"value":3365494,"limit":52428800}},"cachereport":{"origin":"mw-web.codfw.main-847495b4dd-psqvd","timestamp":"20241128121734","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Perl Compatible Regular Expressions","url":"https:\/\/en.wikipedia.org\/wiki\/Perl_Compatible_Regular_Expressions","sameAs":"http:\/\/www.wikidata.org\/entity\/Q125267","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q125267","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":"2005-04-09T03:24:10Z","dateModified":"2024-10-30T20:27:37Z","headline":"software library for interpreting regular expressions"}</script> </body> </html>

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