Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression
Processing...

Test String

Code Generator

Generated Code

import re regex = re.compile(r"[^#]wfLoadExtension\(\s*'(?<name>\S+)'\s*\);(?<comment>[^\n]*)\n", flags=re.MULTILINE) test_str = ("# Protect against web entry\n" "if ( !defined( 'MEDIAWIKI' ) ) {\n" " exit;\n" "}\n\n" "#Debug Settings\n" "if ( getenv( 'MW_SHOW_EXCEPTION_DETAILS' ) === 'true' ) {\n" "# error_reporting( -1 );\n" "# ini_set( 'display_errors', 1 );\n" "# $wgShowExceptionDetails = true;\n" "}\n\n" "########################### Core Settings ##########################\n" "#local time zone\n" "# we have to use \"UTC\" here, otherwise SMW stores time values with reference to the local time zone\n" "# see also: https://www.semantic-mediawiki.org/wiki/Help:Type_Date\n" "$wgLocaltimezone = \"UTC\";\n" "#$wgLocaltimezone = getenv( 'MW_TIME_ZONE' );\n" "# instead we store the timezone param as default user timezone setting\n" "# the offset is dynamically calculated, e.g. 'ZoneInfo|120|Europe/Berlin';\n" "date_default_timezone_set('UTC');\n" "$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|' \n" " . timezone_offset_get(\n" " new DateTimeZone( getenv( 'MW_TIME_ZONE' ) ), \n" " new DateTime( 'now', new DateTimeZone( getenv( 'MW_TIME_ZONE' ) ) )\n" " ) / 60\n" " . '|' . getenv( 'MW_TIME_ZONE' );\n\n" "# Site language code, should be one of the list in ./languages/Names.php\n" "# we have to use 'en' here for technical reasons (namespace and smw property names)\n" "$wgLanguageCode = 'en';\n" "# instead, we set the lang param as default user interface lang\n" "# see also: https://www.mediawiki.org/wiki/Manual:$wgDefaultUserOptions\n" "$wgDefaultUserOptions['language'] = getenv( 'MW_SITE_LANG' );\n\n" "# we have to override the options loading to apply our defaults\n" "# https://www.mediawiki.org/wiki/Manual_talk:$wgDefaultUserOptions#Setting_$wgDefaultUserOptions['language']_=_'de';_fails\n" "$wgHooks['LoadUserOptions'][] = function( $user, array &$options ) use ($wgDefaultUserOptions) {\n" " # lookup explicite user settings\n" " $dbr = wfGetDB( DB_MASTER );\n" " $res = $dbr->select(\n" " 'user_properties',\n" " [ 'up_property', 'up_value' ],\n" " [ 'up_user' => $user->getId() ],\n" " );\n" " $data = [];\n" " foreach ( $res as $row ) {\n" " if ( $row->up_value === '0' ) {\n" " $row->up_value = 0;\n" " }\n" " $data[$row->up_property] = $row->up_value;\n" " }\n\n" " # apply default timezone if not set\n" " if (!array_key_exists('timecorrection', $data)) $options['timecorrection'] = $wgDefaultUserOptions['timecorrection'];\n\n" " # apply default language if not set\n" " //if (!array_key_exists('language', $data)) $options['language'] = $wgDefaultUserOptions['language']; // does not work with Extension:ULS, prevents changing the language via settings\n" "};\n\n" "#$wgHooks['UserGetLanguageObject'][] = function( $user, &$code ) {\n" "# $code = $user->getOption( 'language' );\n" "#};\n\n" "## The protocol and server name to use in fully-qualified URLs => set in Custom settings\n" "$wgServer = getenv( 'MW_SITE_SERVER' );\n\n" "# The name of the site. This is the name of the site as displayed throughout the site.\n" "$wgSitename = getenv( 'MW_SITE_NAME' );\n\n" "# Default skin: you can change the default skin. Use the internal symbolic\n" "# names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector', 'chameleon':\n" "wfLoadExtension( 'Bootstrap' );\n" "$wgDefaultSkin = getenv( 'MW_DEFAULT_SKIN' );\n" "$wgCitizenTableNowrapClasses[] = 'info_box'; # disable wrapping of info_box tables\n" "$wgCitizenSearchGateway = \"smwAskApi\";\n" "$wgCitizenSearchSmwApiAction = \"compoundquery\";\n" "$wgCitizenSearchSmwAskApiQueryTemplate = \"\n" "[[HasNormalizedLabel::\\${input_normalized}]][[HasOswId::!~*#*]];?HasLabel=displaytitle;?HasImage=thumbnail;?HasDescription=desc;limit=1\n" "|[[HasNormalizedLabel::~*\\${input_normalized_tokenized}*]][[HasOswId::!~*#*]];?HasLabel=displaytitle;?HasImage=thumbnail;?HasDescription=desc;limit=7\n" "\";\n\n" "# InstantCommons allows wiki to use images from http://commons.wikimedia.org\n" "$wgUseInstantCommons = getenv( 'MW_USE_INSTANT_COMMONS' );\n\n" "# Name used for the project namespace. The name of the meta namespace (also known as the project namespace), used for pages regarding the wiki itself.\n" "#$wgMetaNamespace = 'Site'; #just an alias. does not work at all of canonical namespace 'project' is created / used by an extension\n" "#$wgMetaNamespaceTalk = 'Site_talk';\n\n" "# The relative URL path to the logo. Make sure you change this from the default,\n" "# or else you'll overwrite your logo when you upgrade!\n" "# logos should actually have different sizes, see https://www.mediawiki.org/wiki/Manual:$wgLogos\n" "$wgLogos = [\n" " '1x' => \"$wgScriptPath/logo.png\",\n" " '1.5x' => \"$wgScriptPath/logo.png\",\n" " '2x' => \"$wgScriptPath/logo.png\",\n" " 'svg' => \"$wgScriptPath/logo.svg\"\n" "];\n\n\n" "# The URL of the site favicon (the small icon displayed next to a URL in the address bar of a browser)\n" "$wgFavicon = \"$wgScriptPath/favicon.ico\";\n\n" "##### Short URLs\n" "## https://www.mediawiki.org/wiki/Manual:Short_URL\n" "$wgArticlePath = '/wiki/$1';\n" "## Also see mediawiki.conf\n\n" "##### Improve performance\n" "# https://www.mediawiki.org/wiki/Manual:$wgMainCacheType\n" "switch ( getenv( 'MW_MAIN_CACHE_TYPE' ) ) {\n" " case 'CACHE_ACCEL':\n" " # APC has several problems in latest versions of MediaWiki and extensions, for example:\n" " # https://www.mediawiki.org/wiki/Extension:Flow#.22Exception_Caught:_CAS_is_not_implemented_in_Xyz.22\n" " $wgMainCacheType = CACHE_ACCEL;\n" " $wgSessionCacheType = CACHE_DB; #This may cause problems when CACHE_ACCEL is used\n" " break;\n" " case 'CACHE_DB':\n" " $wgMainCacheType = CACHE_DB;\n" " break;\n" " case 'CACHE_DB':\n" " $wgMainCacheType = CACHE_DB;\n" " break;\n" " case 'CACHE_ANYTHING':\n" " $wgMainCacheType = CACHE_ANYTHING;\n" " break;\n" " case 'CACHE_MEMCACHED':\n" " # Use Memcached, see https://www.mediawiki.org/wiki/Memcached\n" " $wgMainCacheType = CACHE_MEMCACHED;\n" " $wgParserCacheType = CACHE_MEMCACHED; # optional\n" " $wgMessageCacheType = CACHE_MEMCACHED; # optional\n" " $wgMemCachedServers = explode( ',', getenv( 'MW_MEMCACHED_SERVERS' ) );\n" " $wgSessionsInObjectCache = true; # optional\n" " $wgSessionCacheType = CACHE_MEMCACHED; # optional\n" " break;\n" " default:\n" " $wgMainCacheType = CACHE_NONE;\n" "}\n\n" "#The path of the temporary directory. see https://www.mediawiki.org/wiki/Manual:$wgTmpDirectory\n" "$wgTmpDirectory = $IP . '/images/temp';\n" "$wgCacheDirectory = $IP . '/cache';\n\n" "########################### Search ############################\n" "wfLoadExtension( 'Elastica' );\n" "wfLoadExtension( 'CirrusSearch' );\n" "$wgCirrusSearchServers = explode( ',', getenv( 'MW_CIRRUS_SEARCH_SERVERS' ) );\n" "$wgSearchType = 'CirrusSearch';\n\n" "//manual fetch a property from the db and index it (does not work as expected)\n" "/*$wgHooks['CirrusSearchBuildDocumentParse'][] = function( \\Elastica\\Document $doc, Title $title, Content $content, ParserOutput $parserOutput ) {\n" " //fetch displaytitle from db\n" " $dbr = wfGetDB( DB_REPLICA );\n" " $displayTitle = $dbr->selectField(\n" " 'page_props',\n" " 'pp_value',\n" " array( 'pp_propname' => 'displaytitle', 'pp_page' => $title->getArticleId() ),\n" " __METHOD__\n" " );\n" " if ( $displayTitle === null || trim($displayTitle) === '' )$doc_title = $title->getText();\n" " else $doc_title = $displayTitle . ' ' . $title->getText();\n" " //echo $doc_title . \"\\n\";\n" " //store displaytitle as title in elastic search document\n" " $doc->set( 'display_title', $doc_title );\n" " //$doc->set( 'title', $doc_title );\n" "};*/\n" "//$wgCirrusSearchPrefixSearchStartsWithAnyWord = true; //Is it ok if the prefix starts on any word in the title or just the first word?\n" "//only in recent version of cirrus MW>1.35\n" "#$wgCirrusSearchCustomPageFields = [\n" "# 'display_title' => 'short_text'\n" "#];\n\n" "//Register display_title as index\n" "$wgHooks['SearchIndexFields'][] = function( array &$fields, SearchEngine $engine ) {\n" " #$engine->Xtes();\n" " if ( !( $engine instanceof CirrusSearch\\CirrusSearch ) ) {\n" " return;\n" " }\n" " $fields['display_title'] = $engine->makeSearchFieldMapping( 'display_title', 'short_text' );\n" "};\n\n" "//rank display_title higher than title\n" "$wgCirrusSearchWeights = [\n" " 'title' => 20,\n" " 'display_title' => 50,\n" " 'redirect' => 15,\n" " 'category' => 8,\n" " 'heading' => 5,\n" " 'opening_text' => 3,\n" " 'text' => 1,\n" " 'auxiliary_text' => 0.5,\n" " 'file_text' => 0.5,\n" "];\n" "$wgCirrusSearchPrefixWeights = [\n" " 'title' => 10,\n" " 'display_title' => 30,\n" " 'redirect' => 1,\n" " 'title_asciifolding' => 7,\n" " 'redirect_asciifolding' => 0.7,\n" "];\n\n" "//allow fuzzy search and \"do you mean\" suggestions\n" "//see also https://www.mediawiki.org/w/index.php?title=Topic:Wj3av65bti5a8v7o&topic_showPostId=wj6z0ty2ut72b3hw#flow-post-wj6z0ty2ut72b3hw\n" "$wgCirrusSearchPhraseSuggestUseText = true;\n\n\n" "//rebuild index with\n" "/*\n" "php /var/www/html/w/extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php --startOver\n" "php /var/www/html/w/extensions/CirrusSearch/maintenance/ForceSearchIndex.php\n" "php /var/www/html/w/maintenance/runJobs.php\n" "*/\n\n" "//alternative SMWSearch\n" "#$wgSearchType = 'SMWSearch';\n" "#$smwgFallbackSearchType = function() {\n" "# return new CirrusSearch\\CirrusSearch();\n" "#};\n" "// The two next parameters are recommended to highlight excerpts\n" "#$smwgElasticsearchConfig['query']['highlight.fragment']['type'] = 'plain'; // or 'unified' or 'fvh'\n" "#$smwgElasticsearchConfig['indexer']['raw.text'] = true;\n\n" "########################### VisualEditor ###########################\n" "wfLoadExtension( 'VisualEditor' );\n" "// Enable by default for everybody\n" "$wgDefaultUserOptions['visualeditor-enable'] = 1;\n" "// Use Visual editor in PageForms\n" "wfLoadExtension( 'VEForAll' );\n" "// Optional: Set VisualEditor as the default for anonymous users\n" "// otherwise they will have to switch to VE\n" "$wgDefaultUserOptions['visualeditor-editor'] = \"visualeditor\";\n" "// Don't allow users to disable it\n" "$wgHiddenPrefs[] = 'visualeditor-enable';\n" "// OPTIONAL: Enable VisualEditor's experimental code features\n" "$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1; \n" "//Whether to allow users to enable the section editing. \n" "$wgVisualEditorEnableVisualSectionEditing = true;\n" "//Whether to enable VisualEditor for every new account. \n" "$wgVisualEditorAutoAccountEnable = true;\n" "//Whether to enable the wikitext source mode inside VisualEditor. \n" "$wgVisualEditorEnableWikitext = true;\n" "$wgDefaultUserOptions['visualeditor-newwikitext'] = 1;\n" "//Whether to enable the visual diff function on the history special page. \n" "$wgVisualEditorEnableDiffPage = true;\n\n" "wfLoadExtension( 'Math' ); # bundled in REL1_39\n" "wfLoadExtension( 'CodeMirror' ); des\n\n" "############ Multimedia & Editors ############\n" "## Other Editors\n" "wfLoadExtension( 'DrawioEditor' );\n" "$wgDrawioEditorBackendUrl = getenv( 'DRAWIO_SERVER' );\n\n" "######################### Page Forms ###################\n" "wfLoadExtension( 'PageForms' );\n\n" "############## Uploads #####################\n" "$wgEnableUploads = getenv( 'MW_ENABLE_UPLOADS' );\n\n" "####################### Bundled extensions #########################\n" "#wfLoadExtension( 'AbuseFilter' );\n" "wfLoadExtension( 'CategoryTree' );\n" "wfLoadExtension( 'Cite' );\n" "wfLoadExtension( 'CiteThisPage' );\n" "wfLoadExtension( 'CodeEditor' );\n" "$wgDefaultUserOptions['usebetatoolbar'] = 1; // user option provided by WikiEditor extension\n" "#wfLoadExtension( 'ConfirmEdit' ); //not needed for private wiki\n" "wfLoadExtension( 'Gadgets' );\n" "wfLoadExtension( 'ImageMap' );\n" "wfLoadExtension( 'InputBox' );\n" "wfLoadExtension( 'Interwiki' );\n" "$wgGroupPermissions['sysop']['interwiki'] = true; // To grant sysops permissions to edit interwiki data\n" "#$wgEnableScaryTranscluding = true; //To enable transclusion from other sites\n" "#wfLoadExtension( 'Math' ); # bundled in REL1_39 but customized\n" "wfLoadExtension( 'MultimediaViewer' );\n" "$wgMediaViewerEnableByDefault = false; //to enable direct download of files\n" "wfLoadExtension( 'Nuke' );\n" "#wfLoadExtension( 'OATHAuth' );\n" "wfLoadExtension( 'PageImages' );\n" "wfLoadExtension( 'ParserFunctions' );\n" "$wgPFEnableStringFunctions = true;\n" "wfLoadExtension( 'PdfHandler' );\n" "wfLoadExtension( 'Poem' );\n" "wfLoadExtension( 'Renameuser' );\n" "wfLoadExtension( 'ReplaceText' );\n" "$wgGroupPermissions['bureaucrat']['replacetext'] = true;\n" "#wfLoadExtension( 'Scribunto' ); # bundled in REL1_39 but customized\n" "wfLoadExtension( 'SecureLinkFixer' );\n" "#wfLoadExtension( 'SpamBlacklist' ); //not needed for private wiki\n" "wfLoadExtension( 'SyntaxHighlight_GeSHi' );\n" "#$wgPygmentizePath = '/usr/bin/pygmentize';\n" "wfLoadExtension( 'TemplateData' );\n" "wfLoadExtension( 'TextExtracts' );\n" "wfLoadExtension( 'TitleBlacklist' );\n" "#wfLoadExtension( 'VisualEditor' ); # bundled in REL1_39 but customized\n" "wfLoadExtension( 'WikiEditor' );\n\n\n" "##### Non-bundled Core Extensions ####\n" "wfLoadExtension( 'MyVariables' ); #additional variables like USERLANGUAGECODE \n\n" "########### Semantic Mediawiki ###############\n" "wfLoadExtension( 'SemanticMediaWiki' );\n" "#strip protocol from MW_SITE_SERVER\n" "enableSemantics( preg_replace( \"#^[^:/.]*[:/]+#i\", \"\", getenv( 'MW_SITE_SERVER' ) ) );\n\n" "#$smwgChangePropagationProtection = false; #temp fix to restore locked pages\n" "$smwgQMaxSize = 50; #increase max query conditions, default 12\n" "$smwgQMaxDepth = 20; #increase property chain query limit, default 4\n" "$maxRecursionDepth = 5; #increase limit of nested templates in query results, default 2\n\n" "$smwgDefaultStore = 'SMWSparqlStore';\n" "$smwgSparqlRepositoryConnector = 'blazegraph';\n" "$smwgSparqlEndpoint[\"query\"] = 'http://graphdb:9999/blazegraph/namespace/kb/sparql';\n" "$smwgSparqlEndpoint[\"update\"] = 'http://graphdb:9999/blazegraph/namespace/kb/sparql';\n" "$smwgSparqlEndpoint[\"data\"] = '';\n\n" "# Optional name of default graph\n" "$smwgSparqlDefaultGraph = getenv( 'MW_SITE_SERVER' ) . '/id/';\n" "# Namespace for export\n" "$smwgNamespace = getenv( 'MW_SITE_SERVER' ) . '/id/';\n" "#needs rebuild: php /var/www/html/w/extensions/SemanticMediaWiki/maintenance/rebuildData.php\n\n" "#$smwgShowFactbox = SMW_FACTBOX_NONEMPTY; #Show factboxes only if they have some content\n" "#$smwgShowFactbox = SMW_FACTBOX_SHOWN; #Enable the factbox to be always shown - has no effect?\n" "$smwgShowFactbox = SMW_FACTBOX_HIDDEN; #Never show it\n\n" "wfLoadExtension( 'SemanticResultFormats' );\n" "wfLoadExtension( 'SemanticCompoundQueries' );\n\n" "#Enable Semantic NS\n" "$smwgNamespacesWithSemanticLinks[NS_MAIN] = true;\n" "$smwgNamespacesWithSemanticLinks[NS_USER] = true;\n" "$smwgNamespacesWithSemanticLinks[NS_PROJECT] = true;\n" "$smwgNamespacesWithSemanticLinks[NS_FILE] = true;\n" "$smwgNamespacesWithSemanticLinks[NS_TEMPLATE] = true;\n" "$smwgNamespacesWithSemanticLinks[NS_HELP] = true;\n" "$smwgNamespacesWithSemanticLinks[NS_CATEGORY] = true;\n" "#some NS need hardcoded IDs, see https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/5281\n" "$smwgNamespacesWithSemanticLinks[102] = true; # SMW_NS_PROPERTY\n" "$smwgNamespacesWithSemanticLinks[114] = true; # SMW_NS_SCHEMA\n" "$smwgNamespacesWithSemanticLinks[108] = true; # SMW_NS_CONCEPT\n" "$smwgNamespacesWithSemanticLinks[690] = true; #Action\n" "$smwgNamespacesWithSemanticLinks[692] = true; #Label\n\n\n" "############# Slots ############\n" "wfLoadExtension( 'WSSlots' );\n" "$wgWSSlotsDefaultSlotRoleLayout = [ \n" " \"display\" => \"none\",\n" " \"region\" => \"center\",\n" " \"placement\" => \"append\"\n" "];\n" "$wgWSSlotsDefinedSlots = [\n" " \"jsonschema\" => [\"content_model\" => \"json\", \"slot_role_layout\" => [ \"region\" => \"footer\", \"display\" => \"details\"]],\n" " \"jsondata\" => [\"content_model\" => \"json\", \"slot_role_layout\" => [ \"region\" => \"footer\", \"display\" => \"details\"]],\n" " \"schema_template\" => [\"content_model\" => \"text\", \"slot_role_layout\" => [ \"display\" => \"none\"]],\n" " \"data_template\" => [\"content_model\" => \"wikitext\", \"slot_role_layout\" => [ \"display\" => \"none\"]],\n" " \"header_template\" => [\"content_model\" => \"wikitext\", \"slot_role_layout\" => [ \"display\" => \"none\"]],\n" " \"footer_template\" => [\"content_model\" => \"wikitext\", \"slot_role_layout\" => [ \"display\" => \"none\"]],\n" " \"header\" => [\n" " \"content_model\" => \"wikitext\",\n" " \"slot_role_layout\" => [\n" " \"display\" => \"plain\",\n" " \"region\" => \"header\",\n" " \"placement\" => \"prepend\"\n" " ]\n" " ],\n" " \"footer\" => [\n" " \"content_model\" => \"wikitext\",\n" " \"slot_role_layout\" => [\n" " \"display\" => \"plain\",\n" " \"region\" => \"footer\",\n" " \"placement\" => \"prepend\"\n" " ]\n" " ],\n" "];\n" "$wgWSSlotsSemanticSlots = [ \"data_template\", \"header\" ];\n" "$wgWSSlotsDoPurge = true;\n" "$wgWSSlotsOverrideActions = false;\n\n" "############# Scribunto #############\n" "wfLoadExtension( 'Scribunto' ); //bundled\n" "$wgScribuntoDefaultEngine = 'luastandalone';\n" "$wgScribuntoUseGeSHi = true;\n" "$wgScribuntoUseCodeEditor = true;\n" "wfLoadExtension( 'SemanticScribunto' );\n\n" "########### CommentStreams ###############\n" "# wfLoadExtension( 'CommentStreams' ); # not enabled by default\n" "# $wgCommentStreamsEnableVoting = true;\n" "# $wgCommentStreamsSuppressLogsFromRCs = false;\n" "# $wgCommentStreamsAllowedNamespaces = []; # not enable by default in any namespace\n\n" "######################## UI #############################\n" "wfLoadExtension( 'DisplayTitle' );\n" "$wgAllowDisplayTitle = true;\n" "$wgRestrictDisplayTitle = false;\n" "wfLoadExtension( 'SimpleBatchUpload' );\n\n" "####################### Custom Extensions ####################\n" "wfLoadExtension( 'FileApi' );\n" "wfLoadExtension( 'MwJson' );\n" "$wgMwJsonSlotRenderResultTransformation = [\n" " \"enabled\" => true,\n" "];\n" "wfLoadExtension( 'OpenSemanticLab' );\n" "$wgExtraSignatureNamespaces = [7100]; #allow signatures in NS LabNote\n" "wfLoadExtension( 'SemanticProperties' );\n" "wfLoadExtension( 'WellplateEditor' );\n" "wfLoadExtension( 'SvgEditor' );\n" "wfLoadExtension( 'SpreadsheetEditor' );\n" "wfLoadExtension( 'ChemEditor' );\n" "wfLoadExtension( 'InteractiveSemanticGraph' );\n" "wfLoadExtension( 'InteractiveSemanticGraph2' );\n" "wfLoadExtension( 'SciFileHandler' );\n" "$wgFileExtensions = array_merge($wgFileExtensions, array(\n" " 'hdf', 'h4', 'hdf4', 'he2', 'h5', 'hdf5', 'he5', # HDF File format\n" " 'dx', 'jdx', 'jcm', # JCAMP-DX\n" " 'mpr', 'mps', 'mpt', # Biologic\n" "));\n" "#wfLoadExtension( 'Chatbot' );\n\n" "####################### Custom Content #####################\n" "wfLoadExtension( 'PageExchange' );\n" "$wgPageExchangeFileDirectories[] = 'https://raw.githubusercontent.com/OpenSemanticLab/PagePackages/main/package_index.txt';\n\n" "$wgPageImagesNamespaces[] = 7000;\n" "$wgPageImagesNamespaces[] = NS_CATEGORY;\n" "$sespgEnabledPropertyList = [\n" " '_PAGEIMG',\n" "];\n\n" "$wgCitizenTableNowrapClasses[] = 'layout-table'; # disable wrapping of layout-table tables") matches = regex.finditer(test_str) for match_num, match in enumerate(matches, start=1): print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}") for group_num, group in enumerate(match.groups(), start=1): print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html