Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
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

/
/
mg

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 = "(?m)^[0-9+-]+[ .][\s\S]*?\n{2}" Local $sString = "__Advertisement :)__" & @CRLF & _ "" & @CRLF & _ "```mermaid" & @CRLF & _ "graph TD" & @CRLF & _ " A[Christmas] -->|Get money| B(Go shopping)" & @CRLF & _ " B --> C{Let me think}" & @CRLF & _ " C -->|One| D[Laptop]" & @CRLF & _ " C -->|Two| E[iPhone]" & @CRLF & _ " C -->|Three| F[Car]" & @CRLF & _ "```" & @CRLF & _ "" & @CRLF & _ "```mermaid" & @CRLF & _ "graph TD" & @CRLF & _ "A[Christmas] -->|Get money| B(Go shopping)" & @CRLF & _ "B --> C{Let me think}" & @CRLF & _ "C -->|One| D[Laptop]" & @CRLF & _ "C -->|Two| E[iPhone]" & @CRLF & _ "C -->|Three| F[Car]" & @CRLF & _ "click A "index.html#link-clicked" "link test"" & @CRLF & _ "click B testClick "click test"" & @CRLF & _ "```" & @CRLF & _ "" & @CRLF & _ "- __[pica](https://nodeca.github.io/pica/demo/)__" & @CRLF & _ "- high quality and fast image resize in browser." & @CRLF & _ "- __[babelfish](https://github.com/nodeca/babelfish/)__" & @CRLF & _ "- developer friendly i18n with plurals support and easy syntax." & @CRLF & _ "" & @CRLF & _ "You will like those projects!" & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "# h1 Heading 8-)" & @CRLF & _ "" & @CRLF & _ "## h2 Heading" & @CRLF & _ "" & @CRLF & _ "### h3 Heading" & @CRLF & _ "" & @CRLF & _ "#### h4 Heading" & @CRLF & _ "" & @CRLF & _ "##### h5 Heading" & @CRLF & _ "" & @CRLF & _ "###### h6 Heading" & @CRLF & _ "" & @CRLF & _ "## Horizontal Rules" & @CRLF & _ "" & @CRLF & _ "___" & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "***" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Typographic replacements" & @CRLF & _ "" & @CRLF & _ "Enable typographer option to see result." & @CRLF & _ "" & @CRLF & _ "(c) (C) (r) (R) (tm) (TM) (p) (P) +-" & @CRLF & _ "" & @CRLF & _ "test.. test... test..... test?..... test!...." & @CRLF & _ "" & @CRLF & _ "!!!!!! ???? ,, -- ---" & @CRLF & _ "" & @CRLF & _ ""Smartypants, double quotes" and 'single quotes'" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Emphasis" & @CRLF & _ "" & @CRLF & _ "**This is bold text**" & @CRLF & _ "" & @CRLF & _ "__This is bold text__" & @CRLF & _ "" & @CRLF & _ "*This is italic text*" & @CRLF & _ "" & @CRLF & _ "_This is italic text_" & @CRLF & _ "" & @CRLF & _ "~~Strikethrough~~" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Blockquotes" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "> Blockquotes can also be nested..." & @CRLF & _ ">> ...by using additional greater-than signs right next to each other..." & @CRLF & _ "> > > ...or with spaces between arrows." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Lists" & @CRLF & _ "" & @CRLF & _ "Unordered" & @CRLF & _ "" & @CRLF & _ "+ Create a list by starting a line with `+`, `-`, or `*`" & @CRLF & _ "+ Sub-lists are made by indenting 2 spaces:" & @CRLF & _ " - Marker character change forces new list start:" & @CRLF & _ " * Ac tristique libero volutpat at" & @CRLF & _ " + Facilisis in pretium nisl aliquet" & @CRLF & _ " - Nulla volutpat aliquam velit" & @CRLF & _ "+ Very easy!" & @CRLF & _ "" & @CRLF & _ "Ordered" & @CRLF & _ "" & @CRLF & _ "1. Lorem ipsum dolor sit amet" & @CRLF & _ "2. Consectetur adipiscing elit" & @CRLF & _ "3. Integer molestie lorem at massa" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "1. You can use sequential numbers..." & @CRLF & _ "1. ...or keep all the numbers as `1.`" & @CRLF & _ "" & @CRLF & _ "Start numbering with offset:" & @CRLF & _ "" & @CRLF & _ "57. foo" & @CRLF & _ "1. bar" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Code [^first]" & @CRLF & _ "" & @CRLF & _ "Inline `code`" & @CRLF & _ "" & @CRLF & _ "Indented code" & @CRLF & _ "" & @CRLF & _ " // Some comments" & @CRLF & _ " line 1 of code" & @CRLF & _ " line 2 of code" & @CRLF & _ " line 3 of code" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Block code "fences"" & @CRLF & _ "" & @CRLF & _ "```" & @CRLF & _ "Sample text here..." & @CRLF & _ "```" & @CRLF & _ "" & @CRLF & _ "Syntax highlighting" & @CRLF & _ "" & @CRLF & _ "``` js" & @CRLF & _ "var foo = function (bar) {" & @CRLF & _ " return bar++;" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "console.log(foo(5));" & @CRLF & _ "```" & @CRLF & _ "" & @CRLF & _ "## Tables" & @CRLF & _ "" & @CRLF & _ "| Option | Description |" & @CRLF & _ "| ------ | ----------- |" & @CRLF & _ "| data | path to data files to supply the data that will be passed into templates. |" & @CRLF & _ "| engine | engine to be used for processing templates. Handlebars is the default. |" & @CRLF & _ "| ext | extension to be used for dest files. |" & @CRLF & _ "" & @CRLF & _ "Right aligned columns" & @CRLF & _ "" & @CRLF & _ "| Option | Description |" & @CRLF & _ "| ------:| -----------:|" & @CRLF & _ "| data | path to data files to supply the data that will be passed into templates. |" & @CRLF & _ "| engine | engine to be used for processing templates. Handlebars is the default. |" & @CRLF & _ "| ext | extension to be used for dest files. |" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Links" & @CRLF & _ "" & @CRLF & _ "[link text](http://dev.nodeca.com)" & @CRLF & _ "" & @CRLF & _ "[link with title](http://nodeca.github.io/pica/demo/ "title text!")" & @CRLF & _ "" & @CRLF & _ "Autoconverted link https://github.com/nodeca/pica (enable linkify to see)" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Images" & @CRLF & _ "" & @CRLF & _ "![Minion](https://octodex.github.com/images/minion.png)" & @CRLF & _ "![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat")" & @CRLF & _ "" & @CRLF & _ "Like links, Images also have a footnote style syntax " & @CRLF & _ "" & @CRLF & _ "![Alt text][id]" & @CRLF & _ "" & @CRLF & _ "With a reference later in the document defining the URL location:" & @CRLF & _ "" & @CRLF & _ "[id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat"" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "## Plugins" & @CRLF & _ "" & @CRLF & _ "The killer feature of `markdown-it` is very effective support of" & @CRLF & _ "[syntax plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin)." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "### [Emojies](https://github.com/markdown-it/markdown-it-emoji)" & @CRLF & _ "" & @CRLF & _ "> Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:" & @CRLF & _ ">" & @CRLF & _ "> Shortcuts (emoticons): :-) :-( 8-) ;)" & @CRLF & _ "" & @CRLF & _ "see [how to change output](https://github.com/markdown-it/markdown-it-emoji#change-output) with twemoji." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "### [Subscript](https://github.com/markdown-it/markdown-it-sub) / [Superscript](https://github.com/markdown-it/markdown-it-sup)" & @CRLF & _ "" & @CRLF & _ "- 19^th^" & @CRLF & _ "- H~2~O" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "### [\<ins>](https://github.com/markdown-it/markdown-it-ins)" & @CRLF & _ "" & @CRLF & _ "++Inserted text++" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "### [\<mark>](https://github.com/markdown-it/markdown-it-mark)" & @CRLF & _ "" & @CRLF & _ "==Marked text==" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "### [Footnotes](https://github.com/markdown-it/markdown-it-footnote)" & @CRLF & _ "" & @CRLF & _ "Footnote 1 link[^first]." & @CRLF & _ "" & @CRLF & _ "Footnote 2 link[^second]." & @CRLF & _ "" & @CRLF & _ "Inline footnote^[Text of inline footnote] definition." & @CRLF & _ "" & @CRLF & _ "Duplicated footnote reference[^second]." & @CRLF & _ "" & @CRLF & _ "[^first]: Footnote **can have markup**" & @CRLF & _ " and multiple paragraphs." & @CRLF & _ "[^second]: Footnote text." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "### [Definition lists](https://github.com/markdown-it/markdown-it-deflist)" & @CRLF & _ "" & @CRLF & _ "Term 1" & @CRLF & _ ": Definition 1" & @CRLF & _ "with lazy continuation." & @CRLF & _ "" & @CRLF & _ "Term 2 with *inline markup*" & @CRLF & _ ": Definition 2" & @CRLF & _ "" & @CRLF & _ " { some code, part of Definition 2 }" & @CRLF & _ "" & @CRLF & _ " Third paragraph of definition 2." & @CRLF & _ "" & @CRLF & _ "_Compact style:_" & @CRLF & _ "" & @CRLF & _ "Term 1" & @CRLF & _ " ~ Definition 1" & @CRLF & _ "" & @CRLF & _ "Term 2" & @CRLF & _ " ~ Definition 2a" & @CRLF & _ " ~ Definition 2b" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "### [Abbreviations](https://github.com/markdown-it/markdown-it-abbr)" & @CRLF & _ "" & @CRLF & _ "This is HTML abbreviation example." & @CRLF & _ "It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on." & @CRLF & _ "*[HTML]: Hyper Text Markup Language" & @CRLF & _ "" & @CRLF & _ "### [Custom containers](https://github.com/markdown-it/markdown-it-container)" & @CRLF & _ "" & @CRLF & _ "::: warning" & @CRLF & _ "*here be dragons*" & @CRLF & _ ":::" 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