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

$re = '/\[\[#(.*)\|(.*)\]\]/i'; $str = '<languages/> <translate> {{TNT|Unmaintained extension}} {{ {{TNTN|Extension}} |name = Agora |type1 = skin |type2 = |status = unmaintained |hook1 = BeforePageDisplay |image = 2013-04-22_Agora_detail_screenshot.png |author = Rob Moen, Trevor Parscal, Munaf Assaf |description = Adds skin-agnostic styles to MediaWiki |license = {{ {{TNTN|EL}} |GNUGPL2+}} |mediawiki = 1.19 - 1.21 |version = 0.0.1 |update = 2013-04-04 |download = {{ {{TNTN|WikimediaDownload}} |Agora}} |readme = {{git file|action=raw|project=mediawiki/extensions/Agora|file=README|text=README}} |needs-updatephp = no |parameters = * $wgAgoraEnabledSiteWide * $wgAgoraEnabledPages * $wgAgoraEnabledActions |example = }} The \'\'\'Agora\'\'\' extension added skin-agnostic CSS styles to MediaWiki, following the [[Special:MyLanguage/Wikimedia Foundation Design|Wikimedia Foundation Design]] principles. The CSS defines various mw-ui-* classes including * <code>.mw.ui-button</code> with many variations * <code>.mw-ui-vform</code> for a container with a vertical "stacked" layout * several utility classes such as <code>mw-ui-flush-left</code> Its test subdirectory has some static HTML pages illustrating their use. == Also in 1.22 core == 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. Thus you can use \'\'context\'\'<code>->getOutput()->addModuleStyles( \'mediawiki.ui\' )</code> to ensure the CSS in core is loaded. ==Installation== {{TNT|ExtensionInstall}} Consult its README file to decide how to enable the extension in pages on your wiki and set its globals accordingly in LocalSettings.php === Verifying the installation === 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\'. 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". === Compass === The extension\'s CSS was generated from [[w:Sass (stylesheet language)|Sass]] <tt>.sccs</tt> files using [http://compass-style.org/ Compass]. You don\'t need Compass to use the CSS files in <tt>modules/css</tt>. Click [[#Installation|installation]]. [[Category:Agora{{translation}}|Category:Agora{{translation}}]] </translate>'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php