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

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?i)\[\[#(.*)\|(.*)\]\]" Local $sString = "<languages/>" & @CRLF & _ "<translate>" & @CRLF & _ "{{TNT|Unmaintained extension}}" & @CRLF & _ "{{ {{TNTN|Extension}}" & @CRLF & _ "|name = Agora" & @CRLF & _ "|type1 = skin" & @CRLF & _ "|type2 = " & @CRLF & _ "|status = unmaintained" & @CRLF & _ "|hook1 = BeforePageDisplay" & @CRLF & _ "|image = 2013-04-22_Agora_detail_screenshot.png" & @CRLF & _ "|author = Rob Moen, Trevor Parscal, Munaf Assaf" & @CRLF & _ "|description = Adds skin-agnostic styles to MediaWiki" & @CRLF & _ "|license = {{ {{TNTN|EL}} |GNUGPL2+}}" & @CRLF & _ "|mediawiki = 1.19 - 1.21" & @CRLF & _ "|version = 0.0.1" & @CRLF & _ "|update = 2013-04-04" & @CRLF & _ "|download = {{ {{TNTN|WikimediaDownload}} |Agora}}" & @CRLF & _ "|readme = {{git file|action=raw|project=mediawiki/extensions/Agora|file=README|text=README}}" & @CRLF & _ "|needs-updatephp = no" & @CRLF & _ "|parameters = * $wgAgoraEnabledSiteWide" & @CRLF & _ "* $wgAgoraEnabledPages" & @CRLF & _ "* $wgAgoraEnabledActions" & @CRLF & _ "|example =" & @CRLF & _ "}}" & @CRLF & _ "" & @CRLF & _ "The '''Agora''' extension added skin-agnostic CSS styles to MediaWiki," & @CRLF & _ "following the [[Special:MyLanguage/Wikimedia Foundation Design|Wikimedia Foundation Design]] principles." & @CRLF & _ "The CSS defines various mw-ui-* classes including" & @CRLF & _ "* <code>.mw.ui-button</code> with many variations" & @CRLF & _ "* <code>.mw-ui-vform</code> for a container with a vertical "stacked" layout" & @CRLF & _ "* several utility classes such as <code>mw-ui-flush-left</code>" & @CRLF & _ "" & @CRLF & _ "Its test subdirectory has some static HTML pages illustrating their use." & @CRLF & _ "" & @CRLF & _ "== Also in 1.22 core ==" & @CRLF & _ "" & @CRLF & _ "As of {{gerrit|55847}}, the same CSS is available in core MediaWiki in release 1.22wmf2 in the [[Special:MyLanguage/ResourceLoader/Default_modules#mediawiki.ui|mediawiki.ui]] module, and you don't need this extension. In release 1.23, the CSS for buttons is split out into a [[Special:MyLanguage/ResourceLoader/Default_modules#mediawiki.ui.button|mediawiki.ui.button]] module." & @CRLF & _ "Thus you can use ''context''<code>->getOutput()->addModuleStyles( 'mediawiki.ui' )</code> to ensure the CSS in core is loaded." & @CRLF & _ "" & @CRLF & _ "==Installation==" & @CRLF & _ "" & @CRLF & _ "{{TNT|ExtensionInstall}}" & @CRLF & _ "Consult its README file to decide how to enable the extension in pages on your wiki and set its globals accordingly in LocalSettings.php" & @CRLF & _ "" & @CRLF & _ "=== Verifying the installation ===" & @CRLF & _ "" & @CRLF & _ "On a page where the extension should provide its CSS according to your configuration, create a submit button and give it the styles 'mw-ui-button blue'." & @CRLF & _ "" & @CRLF & _ "To see if the extension is sent down on the current page, in a browser console enter <kbd>mw.loader.state( 'ext.agora.base' )</kbd>; it should return "ready"." & @CRLF & _ "" & @CRLF & _ "=== Compass ===" & @CRLF & _ "" & @CRLF & _ "The extension's CSS was generated from [[w:Sass (stylesheet language)|Sass]] <tt>.sccs</tt> files using [http://compass-style.org/ Compass]." & @CRLF & _ "You don't need Compass to use the CSS files in <tt>modules/css</tt>. Click [[#Installation|installation]]." & @CRLF & _ "" & @CRLF & _ "[[Category:Agora{{translation}}|Category:Agora{{translation}}]]" & @CRLF & _ "</translate>" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm