Regular Expressions 101

Save & Share

  • Regex Version: ver. 8
  • 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
No Match

r"
"
gm

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)@(?P<citekey>\w[\w:.#$%&\-+?<>~/]*\w+)" Local $sString = "The [Pandoc manual](https://pandoc.org/MANUAL.html#citations) defines the following syntax for citation keys:" & @CRLF & _ "" & @CRLF & _ "> The citation key must begin with a letter, digit, or `_`, and may contain alphanumerics, `_`, and internal punctuation characters (`:.#$%&-+?<>~/`). Here are some examples:" & @CRLF & _ "" & @CRLF & _ "## Valid citekeys" & @CRLF & _ "" & @CRLF & _ "Manubot supports citations like `@source:identifier`, where `source` is one of the options described below. The citekeys in this section are valid according to the Pandoc syntax." & @CRLF & _ "" & @CRLF & _ "1. DOI (Digital Object Identifier), cite like `@doi:10.15363/thinklab.4`." & @CRLF & _ " Shortened versions of DOIs can be created at [shortdoi.org](http://shortdoi.org/)." & @CRLF & _ " shortDOIs begin with `10/` rather than `10.` and can also be cited." & @CRLF & _ " For example, Manubot will expand `@doi:10/993` to the DOI above." & @CRLF & _ " We suggest using shortDOIs to cite DOIs containing forbidden characters, such as `(` or `)`." & @CRLF & _ "2. PubMed Central ID, cite like `@pmcid:PMC4497619`." & @CRLF & _ "3. PubMed ID, cite like `@pmid:26158728`." & @CRLF & _ "4. _arXiv_ ID, cite like `@arxiv:1508.06576v2`." & @CRLF & _ "5. ISBN (International Standard Book Number), cite like `@isbn:9781339919881`." & @CRLF & _ "6. URL / webpage, cite like `@url:https://nyti.ms/1QUgAt1`." & @CRLF & _ " URL citations can be helpful if the above methods return incorrect metadata." & @CRLF & _ " For example, `@doi:10.1038/ng.3834` [incorrectly handles](https://github.com/manubot/manubot/issues/158) the consortium name resulting in a blank author, while `@url:https://doi.org/10.1038/ng.3834` succeeds." & @CRLF & _ " Similarly, `@url:https://doi.org/10.1101/142760` is a [workaround](https://github.com/manubot/manubot/issues/16) to set the journal name of bioRxiv preprints to _bioRxiv_." & @CRLF & _ "7. Wikidata Items, cite like `@wikidata:Q50051684`." & @CRLF & _ " Note that anyone can edit or add records on [Wikidata](https://www.wikidata.org), so users are encouraged to contribute metadata for hard-to-cite works to Wikidata as an alternative to using a `raw` citation." & @CRLF & _ "8. For references that do not have any of the persistent identifiers above, use a raw citation like `@raw:old-manuscript`." & @CRLF & _ " Metadata for raw citations must be provided manually." & @CRLF & _ "" & @CRLF & _ "Cite multiple items at once like:" & @CRLF & _ "" & @CRLF & _ "```md" & @CRLF & _ "Here is a sentence with several citations [@doi:10.15363/thinklab.4; @pmid:26158728; @arxiv:1508.06576; @isbn:9780394603988]." & @CRLF & _ "```" & @CRLF & _ "" & @CRLF & _ "More information at https://github.com/manubot/rootstock/blob/master/USAGE.md#citations" & @CRLF & _ "" & @CRLF & _ "## Invalid citekeys" & @CRLF & _ "" & @CRLF & _ "Citekeys in this section would be nice to support, but notice that they do not completely match the regex:" & @CRLF & _ "" & @CRLF & _ "Citekey with parentheses @doi:10.1016/S0022-2836(05)80360-2" & @CRLF & _ "Citekey with closing slash @https://www.google.com/" & @CRLF & _ "Citekey with equal sign @https://openreview.net/forum?id=HkwoSDPgg" & @CRLF & _ "" & @CRLF & _ "See https://github.com/jgm/pandoc/issues/6026 for discussion on a more flexible markdown syntax for citation keys." & @CRLF & _ "" & @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