Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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)^(\(?([\d \-\)\–\+\/\(.]+){5}\)?([ .\-–\/]?)([\d]+))$" Local $sString = "US (North American) Phone Numbers" & @CRLF & _ "1-800-123-4567" & @CRLF & _ "(123)456-7890" & @CRLF & _ "1234567890" & @CRLF & _ "123-456-7890" & @CRLF & _ "123.456.7890" & @CRLF & _ "123 456 7890" & @CRLF & _ "(123) 456 7890" & @CRLF & _ "UK Phone Numbers" & @CRLF & _ "+447222555555" & @CRLF & _ "+44 7222 555 555" & @CRLF & _ "(0722) 5555555 #2222" & @CRLF & _ "French Phone Numbers" & @CRLF & _ "0123456789" & @CRLF & _ "01 23 45 67 89" & @CRLF & _ "01.23.45.67.89" & @CRLF & _ "0123 45.67.89" & @CRLF & _ "0033 123-456-789" & @CRLF & _ "+33-1.23.45.67.89" & @CRLF & _ "+33 – 123 456 789" & @CRLF & _ "+33(0) 123 456 789" & @CRLF & _ "+33 (0)123 45 67 89" & @CRLF & _ "+33 (0)1 2345-6789" & @CRLF & _ "+33(0) – 123456789" & @CRLF & _ "German Phone Numbers" & @CRLF & _ "(06442) 3933023" & @CRLF & _ "(02852) 5996-0" & @CRLF & _ "(042) 1818 87 9919" & @CRLF & _ "06442 / 3893023" & @CRLF & _ "06442 / 38 93 02 3" & @CRLF & _ "06442/3839023" & @CRLF & _ "042/ 88 17 890 0" & @CRLF & _ "+49 221 549144 – 79" & @CRLF & _ "+49 221 – 542194 79" & @CRLF & _ "+49 (221) – 542944 79" & @CRLF & _ "0 52 22 – 9 50 93 10" & @CRLF & _ "+49(0)121-79536 – 77" & @CRLF & _ "+49(0)2221-39938-113" & @CRLF & _ "+49 (0) 1739 906-44" & @CRLF & _ "+49 (173) 1799 806-44" & @CRLF & _ "0214154914479" & @CRLF & _ "02141 54 91 44 79" & @CRLF & _ "01517953677" & @CRLF & _ "+491517953677" & @CRLF & _ "015777953677" & @CRLF & _ "02162 – 54 91 44 79" & @CRLF & _ "(02162) 54 91 44 79" & @CRLF & _ "Chinese Phone Numbers" & @CRLF & _ "0936-4211235" & @CRLF & _ "89076543" & @CRLF & _ "010-12345678-1234" & @CRLF & _ "Chinese Mobile Phone Numbers" & @CRLF & _ "008618311006933" & @CRLF & _ "+8617888829981" & @CRLF & _ "1911925564" & @CRLF & _ "India Phone Numbers" & @CRLF & _ "03595-259506" & @CRLF & _ "03592 245902" & @CRLF & _ "03598245785" & @CRLF & _ "9775876662" & @CRLF & _ "0 9754845789" & @CRLF & _ "0-9778545896" & @CRLF & _ "+91 9456211568" & @CRLF & _ "91 9857842356" & @CRLF & _ "919578965389" & @CRLF & _ "Brazilian Phone Numbers" & @CRLF & _ "(12) 123 1234" & @CRLF & _ "(01512) 123 1234" & @CRLF & _ "(0xx12) 1234 1234" & @CRLF & _ "Australian Phone Numbers" & @CRLF & _ "0732105432" & @CRLF & _ "1300333444" & @CRLF & _ "131313" & @CRLF & _ "Dutch Phone Numbers" & @CRLF & _ "+31235256677" & @CRLF & _ "+31(0)235256677" & @CRLF & _ "023-5256677" & @CRLF & _ "Sweden Phone Numbers" & @CRLF & _ "+46 8 123 456 78" & @CRLF & _ "08-123 456 78" & @CRLF & _ "0123-456 78" & @CRLF & _ "thx to https://regexpattern.com/phone-number/" 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