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
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)\d{1,} ([a-zA-Z][a-zA-Z0-9]{0,15}) = (\-?([a-zA-Z][a-zA-Z0-9]{0,15}|[0-9]{1,}) (\+|\-|\*|\/) \-?([a-zA-Z][a-zA-Z0-9]{0,15}|[0-9]{1,})|\-?([a-zA-Z][a-zA-Z0-9]{0,15}|[0-9]{1,}))$" Local $sString = "1 EAr = 597 / -39" & @CRLF & _ "2 HmRP = 2741 + 11" & @CRLF & _ "3 sM = 581 - sM" & @CRLF & _ "4 PhybLRr5MQBJ = PhybLRr5MQBJ / 790" & @CRLF & _ "5 0ZL = 0ZL * -324" & @CRLF & _ "6 x8cYcKIald x8cYcKIald - 55" & @CRLF & _ "7 ZmgtleHAEeeM = 2598 + " & @CRLF & _ "8 uDM49CqM # -4768 * uDM49CqM" & @CRLF & _ "9 hdKM5gcTnhFg5EH = 272 + qq8d" & @CRLF & _ "10 4DDUktOAQfGsBjB1 = 49 - 4DDUktOAQfGsBjB1" & @CRLF & _ "11 xhy2eVHuaC3 = -50`8125" & @CRLF & _ "12 nzp60O = nzp60O * 273" & @CRLF & _ "13 kqThXnQ = -510 + kqThXnQ" & @CRLF & _ "14 waZ3dysjsj=waZ3dysjsj" & @CRLF & _ "15 0ltqh8pZUhY6KM = -7068" & @CRLF & _ "16 n98IKfQ0KhR4Ogq = 78 * 2637" & @CRLF & _ "17 wpj = wpj wpj" & @CRLF & _ "18 vLnyRzQQKmc0NVU = vLnyRzQQKmc0NVU - vLnyRzQQKmc0NVU" & @CRLF & _ "19 U4ZwSPYGFKnmqpn = -7015 + U4ZwSPYGFKnmqpn" & @CRLF & _ "20 h25bRmbGpKw4X = -71" & @CRLF & _ "21 N1sLOGPryc4A = 728 * N1sLOGPryc4A" & @CRLF & _ "22 j4UcrnDnR0Aj = 6844" & @CRLF & _ "23 qtMieAJ = qtMieAJ * i" & @CRLF & _ "24 V7rqZ2FFN7lj = V7rqZ2FFN7lj(5897" & @CRLF & _ "25 kMGA34oRhAn78Eh = kMGA34oRhAn78Eh,-29" & @CRLF & _ "26 taVAdRtz3Y = taVAdRtz3Y + 418-" & @CRLF & _ "27 pIgMkrSRYdhJm9 = pIgMkrSRYdhJm9 pIgMkrSRYdhJm9" & @CRLF & _ "28 3bB5T7QCQ = 281" & @CRLF & _ "29 U3BuJ = -4695 / -106" & @CRLF & _ "30 gX4Qvq1p3kdYQ0G = -79 + gX4Qvq1p3kdYQ0G" & @CRLF & _ "31 NpsotxU2vyDvS7By = NpsotxU2vyDvS7By + " & @CRLF & _ "32 S9gibae = 601 - -7778" & @CRLF & _ "33 li ! li * -844" & @CRLF & _ "34 bG14MTpgtsqrM81 = bG14MTpgtsqrM81 - 48" & @CRLF & _ "35 Qkt3o7sQ=Qkt3o7sQ" & @CRLF & _ "36 nHeIDT7mMLaF = nHeIDT7mMLaF" & @CRLF & _ "37 sJsw1759 = sJsw1759 + sJsw1759" & @CRLF & _ "38 oBnw09 = 53@oBnw09" & @CRLF & _ "39 axLq = axLq" & @CRLF & _ "40 L4gNW62VVgP = -950" & @CRLF & _ "41 xKLg00YtISqDTYl = -9432" & @CRLF & _ "42 LOTLlJjEVnefSGl = LOTLlJjEVnefSGl * LOTLlJjEVnefSGl" & @CRLF & _ "43 hxC1DY0xwaY = hxC1DY0xwaY / hxC1DY0xwaY" & @CRLF & _ "44 cAHDrb = -5613 -4948" & @CRLF & _ "45 O3RuYn74ES -36 - -1709" & @CRLF & _ "46 DOiOK0R2e3a9TSoL = 710 - DOiOK0R2e3a9TSoL" & @CRLF & _ "47 NSgi3k5kh0sXmB = NSgi3k5kh0sXmB" & @CRLF & _ "48 yaZuVW5m = 954" & @CRLF & _ "49 gush = -211 * 0114" & @CRLF & _ "50 OMPLI3wO4ZSSqvK = OMPLI3wO4ZSSqvK -73" 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