Regular Expressions 101

Save & Share

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

/
/
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)((asia|europe|us|australia)|((north|south)(america|africa)))-((east|west|central|north|south)|((north|south)(east)))([0-9]{1,2})" Local $sString = "(east|west|central|north)?(north|south)?(east)[0-9]{1,2}" & @CRLF & _ "(east|west|central|north)(north|south)(east)[0-9]{1,2}" & @CRLF & _ "" & @CRLF & _ "(north|south)(america)" & @CRLF & _ "" & @CRLF & _ "FireStore Regions" & @CRLF & _ "us-west1 oregon" & @CRLF & _ "us-west2 Los Angeles" & @CRLF & _ "us-west3 Tuz Gölü şehri" & @CRLF & _ "us-west4 Las Vegas" & @CRLF & _ "northamerica-northeast1 Montreal" & @CRLF & _ "northafrica-west3" & @CRLF & _ "southafrica-east1" & @CRLF & _ "us-east1 Güney Carolina" & @CRLF & _ "us-east4 Kuzey Virginia" & @CRLF & _ "southamerica-east1 Sao Paulo" & @CRLF & _ "europe-west2 Londra" & @CRLF & _ "europe-west4" & @CRLF & _ "europe-west3 Frankfurt" & @CRLF & _ "europe-central2 Varşova" & @CRLF & _ "europe-west6 Zürih" & @CRLF & _ "asia-south1 Bombay" & @CRLF & _ "asia-southeast1 Singapur" & @CRLF & _ "asia-southeast2 Cakarta" & @CRLF & _ "asia-east2 Hong Kong" & @CRLF & _ "asia-east1 Tayvan" & @CRLF & _ "asia-northeast1 Tokyo" & @CRLF & _ "asia-northeast2 Osaka" & @CRLF & _ "asia-northeast3 Seul" & @CRLF & _ "australia-southeast1 Sidney" & @CRLF & _ "australia-southeast2" & @CRLF & _ "" & @CRLF & _ "australia-southeast" & @CRLF & _ "" & @CRLF & _ "Function Regions" & @CRLF & _ "" & @CRLF & _ "asia-east1 (Tayvan)" & @CRLF & _ "asia-east2 (Hong Kong)" & @CRLF & _ "asia-northeast1 (Tokyo)" & @CRLF & _ "asia-northeast2 (Osaka)" & @CRLF & _ "europe-west1 (Belçika) " & @CRLF & _ "europe-west2 (Londra)" & @CRLF & _ "us-central1 (Iowa)" & @CRLF & _ "us-east1 (Güney Karolina)" & @CRLF & _ "us-east4 (Kuzey Virginia)" & @CRLF & _ "us-west1 (Oregon)" & @CRLF & _ "asia-northeast3 (Seul)" & @CRLF & _ "asia-southeast1 (Singapur)" & @CRLF & _ "asia-southeast2 (Cakarta)" & @CRLF & _ "asia-south1 (Mumbai)" & @CRLF & _ "australia-southeast1 (Sidney)" & @CRLF & _ "europe-central2 (Varşova)" & @CRLF & _ "europe-west3 (Frankfurt)" & @CRLF & _ "europe-west6 (Zürih) " & @CRLF & _ "northamerica-northeast1 (Montreal) " & @CRLF & _ "southamerica-east1 (Sao Paulo) " & @CRLF & _ "us-west2 (Los Angeles)" & @CRLF & _ "us-west3 (Salt Lake City)" & @CRLF & _ "us-west4 (Las Vegas)" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "asia-east1 (Tayvan) us-west2 (Los Angeles) europe-west1 (Belçika)" & @CRLF & _ "us-west3 (Salt Lake City) asia-northeast1 (Tokyo) southamerica-east1 (Sao Paulo)" & @CRLF & _ "us-west4 (Las Vegas) asia-east2 (Hong Kong) northamerica-northeast1 (Montreal)" & @CRLF & _ "europe-west2 (Londra) asia-south1 (Mumbai) europe-west3 (Frankfurt)" & @CRLF & _ "us-central1 (Iowa) europe-central2 (Varşova) europe-west6 (Zürih)" & @CRLF & _ "us-east1 (Güney Karolina)" & @CRLF & _ "asia-northeast3 (Seul)" & @CRLF & _ "us-east4 (Kuzey Virginia)" & @CRLF & _ "australia-southeast1 (Sidney)" & @CRLF & _ "us-west1 (Oregon)" & @CRLF & _ "asia-southeast2 (Cakarta)" & @CRLF & _ "asia-southeast1 (Singapur)" 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