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

/
/
gmi

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 = "(?mi)^(?:((?:IT|SM)\d{2}\s?[A-Z]{1}\d{3}\s?(\d{4}\s?){4}\d{3})|(NL\d{2}\s?[A-Z]{4}\s?(\d{4}\s?){2}\d{2})|(LV\d{2}\s?[A-Z]{4}\s?(\d{4}\s?){3}\d{1})|((?:BG|GB|IE)\d{2}\s?[A-Z]{4}\s?(\d{4}\s?){3}\d{2})|(GI\d{2}\s?[A-Z]{4}\s?(\d{4}\s?){3}\d{3})|(RO\d{2}\s?[A-Z]{4}\s?(\d{4}\s?){4})|(MT\d{2}\s?[A-Z]{4}\s?(\d{4}\s?){5}\d{3})|(NO\d{2}\s?(\d{4}\s?){2}\d{3})|((?:DK|FI|FO)\d{2}\s?(\d{4}\s?){3}\d{2})|((?:SI)\d{2}\s?(\d{4}\s?){3}\d{3})|((?:AT|EE|LU|LT)\d{2}\s?(\d{4}\s?){4})|((?:HR|LI|CH)\d{2}\s?(\d{4}\s?){4}\d)|((?:DE)\d{2}\s?(\d{4}\s?){4}\d{2})|((?:CZ|ES|SK|SE)\d{2}\s?(\d{4}\s?){5})|(PT\d{2}\s?(\d{4}\s?){5}\d)|((?:IS)\d{24})|((?:BE)\d{2}\s?(\d{4}\s?){3})|((?:FR|MC|GR)\d{2}\s?([0-9A-Z]{4}\s?){5}\d{3})|((?:PL|HU|CY)\d{2}\s?(\d{4}\s?){6}))$" Local $sString = "AD14 0008 0001 0012 3456 7890" & @CRLF & _ "BE23 0003 2399 3244" & @CRLF & _ "AT48 3200 0000 1234 5864 " & @CRLF & _ "BE71 0961 2345 6769 " & @CRLF & _ "BG18 RZBB 9155 0123 4567 89" & @CRLF & _ "HR17 2360 0001 1012 3456 5" & @CRLF & _ "CY21 0020 0195 0000 3570 0123 4567" & @CRLF & _ "CZ55 0800 0000 0012 3456 7899" & @CRLF & _ "DK95 2000 0123 4567 89" & @CRLF & _ "EE47 1000 0010 2014 5685 " & @CRLF & _ "FI14 1009 3000 1234 58" & @CRLF & _ "FR76 3000 6000 0112 3456 7890 189" & @CRLF & _ "DE75 5121 0800 1245 1261 99" & @CRLF & _ "GI04 BARC 0000 0123 4567 890" & @CRLF & _ "GR96 0810 0010 0000 0123 4567 890" & @CRLF & _ "HU93 1160 0006 0000 0000 1234 5676" & @CRLF & _ "IS75 0001 1212 3456 3108 9620 99" & @CRLF & _ "IE64 IRCE 9205 0112 3456 78" & @CRLF & _ "IT60 X054 2811 1010 0000 0123 456" & @CRLF & _ "LV97 HABA 0012 3456 7891 0" & @CRLF & _ "LI74 0880 6123 4567 8901 2" & @CRLF & _ "LT60 1010 0123 4567 8901 " & @CRLF & _ "LU12 0010 0012 3456 7891 " & @CRLF & _ "MT31 MALT 0110 0000 0000 0000 0000 123" & @CRLF & _ "MC58 1009 6180 7901 2345 6789 085" & @CRLF & _ "NL02 ABNA 0123 4567 89" & @CRLF & _ "NO83 3000 1234 567" & @CRLF & _ "PL10 1050 0099 7603 1234 5678 9123" & @CRLF & _ "PT50 0027 0000 0001 2345 6783 3" & @CRLF & _ "RO09 BCYP 0000 0012 3456 7890" & @CRLF & _ "SM76 P085 4009 8121 2345 6789 123" & @CRLF & _ "SK89 7500 0000 0000 1234 5671" & @CRLF & _ "SI56 1920 0123 4567 892" & @CRLF & _ "ES79 2100 0813 6101 2345 6789" & @CRLF & _ "SE72 8000 0810 3400 0978 3242" & @CRLF & _ "CH56 0483 5012 3456 7800 9" & @CRLF & _ "GB33 BUKB 2020 1555 5555 55" & @CRLF & _ "VA59 0011 2300 0012 3456 78" & @CRLF & _ "AL35 2021 1109 0000 0000 0123 4567" & @CRLF & _ "AZ96 AZEJ 0000 0000 0012 3456 7890" & @CRLF & _ "BH02 CITI 0000 1077 1816 11" & @CRLF & _ "BA39 3385 8048 0021 1234 " & @CRLF & _ "BR15 0000 0000 0000 1093 2840 814P 2" & @CRLF & _ "CR23 0151 0841 0026 0123 45" & @CRLF & _ "FO92 6460 0123 4567 89" & @CRLF & _ "GL89 6471 0123 4567 89" & @CRLF & _ "DO22 ACAU 0000 0000 0001 2345 6789" & @CRLF & _ "EG80 0002 0001 5678 9012 3451 8000 2" & @CRLF & _ "GE60 NB00 0000 0123 4567 89" & @CRLF & _ "GT20 AGRO 0000 0000 0012 3456 7890" & @CRLF & _ "IL17 0108 0000 0001 2612 345" & @CRLF & _ "JO71 CBJO 0000 0000 0000 1234 5678 90" & @CRLF & _ "KZ56 3190 0000 1234 4567 " & @CRLF & _ "XK05 1212 0123 4567 8906 " & @CRLF & _ "KW81 CBKU 0000 0000 0000 1234 5601 01" & @CRLF & _ "LB92 0007 0000 0000 1231 2345 6123" & @CRLF & _ "MK07 2000 0278 5123 453" & @CRLF & _ "MR13 0002 0001 0100 0012 3456 753" & @CRLF & _ "MU43 BOMM 0101 1234 5678 9101 000M UR" & @CRLF & _ "MD21 EX00 0000 0000 0123 4567" & @CRLF & _ "ME25 5050 0001 2345 6789 51" & @CRLF & _ "PK36 SCBL 0000 0011 2345 6702" & @CRLF & _ "PS92 PALS 0000 0000 0400 1234 5670 2" & @CRLF & _ "QA54 QNBA 0000 0000 0000 6931 2345 6" & @CRLF & _ "LC14 BOSL 1234 5678 9012 3456 7890 1234" & @CRLF & _ "ST23 0002 0000 0289 3557 1014 8" & @CRLF & _ "SA44 2000 0001 2345 6789 1234" & @CRLF & _ "RS35 1050 0812 3123 1231 73" & @CRLF & _ "TL38 0010 0123 4567 8910 106" & @CRLF & _ "TN59 0401 8104 0049 4271 2345" & @CRLF & _ "TR32 0010 0099 9990 1234 5678 90" & @CRLF & _ "AE46 0090 0000 0012 3456 789" & @CRLF & _ "VG21 PACG 0000 0001 2345 6789" & @CRLF & _ "UA90 3052 9929 9000 4149 1234 5678 9" & @CRLF & _ "SC52 BAHL 0103 1234 5678 9012 3456 USD" & @CRLF & _ "IQ20 CBIQ 8618 0010 1010 500" & @CRLF & _ "BY86 AKBB 1010 0000 0029 6600 0000" & @CRLF & _ "SV43 ACAT 0000 0000 0000 0012 3123" & @CRLF & _ "LY38 0210 0100 0000 1234 5678 9" & @CRLF & _ "SD88 1112 3456 7890 12 " 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