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

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(((\+49\ ))|(0))\d{3,4}\ (\d{7}|\d{6}(\-\d{2})?)" Local $sString = "// valid" & @CRLF & _ "//Landline" & @CRLF & _ "0221 999985" & @CRLF & _ "0221 999985-80" & @CRLF & _ "// Mobile" & @CRLF & _ "01578 1234567" & @CRLF & _ "// International" & @CRLF & _ "+49 221 999985" & @CRLF & _ "+49 221 999985-60" & @CRLF & _ "+49 1578 1234567" & @CRLF & _ "" & @CRLF & _ "// invalid" & @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 & _ "0173173990644" & @CRLF & _ "+4922154219479" & @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 & _ "saddsadasdasd" & @CRLF & _ "asdasd" & @CRLF & _ "asdasd asdasd asd" & @CRLF & _ "asdasd" & @CRLF & _ "kjn asohas asdoiasd" & @CRLF & _ "23434 234 234 23" & @CRLF & _ "323" & @CRLF & _ "23434 234----234" & @CRLF & _ "///// ----" & @CRLF & _ "// id8834 3493934 //" & @CRLF & _ "" Local $sSubst = "" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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