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)((((\+49(\s?))|(049(\s?))?)[.\-\\\/]*?((\(0\))|0)?\s?(151|152|157|159|160|162|163|17)|((\+43(\s?))|(043(\s?))?)[.\-\\\/]*?((\(0\))|0)?\s?(650|660|663|664|676|678|680|681|688|699)|((\+41(\s?))|(041(\s?))?)[.\-\\\/]*?((\(0\))|0)?\s?(76|77|78|79)))([ .\-\\\/]*[0-9]+){7,}" Local $sString = "===================================" & @CRLF & _ "====== sms phone ==================" & @CRLF & _ "===================================" & @CRLF & _ "" & @CRLF & _ "Fon +49 33 27. 46 88 13" & @CRLF & _ "Fax +49 33 27. 46 88 46" & @CRLF & _ "" & @CRLF & _ "+49 (0) 173 / 241 38 66" & @CRLF & _ "" & @CRLF & _ "Neuenhofer Str. 6 Tel. 02244 - 8 79 96 39" & @CRLF & _ "53639 Königswinter Mobil: 0151 - 23 58 73 18" & @CRLF & _ "" & @CRLF & _ "tel 030/ 5779 9182" & @CRLF & _ "fax 030/ 5779 9182" & @CRLF & _ "mob 0178/ 935 44 00" & @CRLF & _ "" & @CRLF & _ "Tel. +49 (0) 9283 - 920 39 01" & @CRLF & _ "Fax +49 (0) 9283 - 920 391" & @CRLF & _ "" & @CRLF & _ "Fon +99-99 99-9 9 99 99- 98" & @CRLF & _ "Mobil +49 - 177 - 999 99 99" & @CRLF & _ "" & @CRLF & _ "Tel.: +49 (0) 99 99 - 77 999 777" & @CRLF & _ "" & @CRLF & _ "0171 -99 99 99 99" & @CRLF & _ "0171 - 99 99 99 99" & @CRLF & _ "" & @CRLF & _ "071195836855" & @CRLF & _ "" & @CRLF & _ "210 Shepherd's Bush Road +49 30 340 604 760" & @CRLF & _ "" & @CRLF & _ "+49 30 340 604 760" & @CRLF & _ "" & @CRLF & _ "Phone: +49 177 2837460" & @CRLF & _ "ZAV Köln: +49 221 29304928" & @CRLF & _ "" & @CRLF & _ "Tel +49 (0)8143 999500" & @CRLF & _ "Fax +49 (0)8143 999500" & @CRLF & _ "Mobil +49 (0)8143 999500" & @CRLF & _ "" & @CRLF & _ "+49 (0) 6731 99 77 99 6" & @CRLF & _ "" & @CRLF & _ "+49 173 9292927" & @CRLF & _ "" & @CRLF & _ "+49 -(0) 173 9292927" & @CRLF & _ "" & @CRLF & _ "Tel. 0621 939393 Memeler Straße 15" & @CRLF & _ "Fax 0283 9193940 67294 Mannheim-Schönau" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "+41 79 419 84 55" & @CRLF & _ "" & @CRLF & _ "Tel. 02938 9987-12" & @CRLF & _ "Fax 02938 9987-12" & @CRLF & _ "" & @CRLF & _ "030.20 14 32 34" & @CRLF & _ "" & @CRLF & _ "Aparmenthotel ***** Telefon +49 (0) 9928 444 09-100" & @CRLF & _ "" & @CRLF & _ "+49(0)23459302939577777" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Mobil: +49 (0) 889 9999 9999" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "T: +43 (0)9999 99 999, F: +43 (0)9999 99 999-4" & @CRLF & _ "" & @CRLF & _ "Tel.: +49 9999 9999999" & @CRLF & _ "" & @CRLF & _ "Mobile (Mauritius): +230 00 00 00 00" & @CRLF & _ "Phone (Germany): +49 (351) 222 22 22" & @CRLF & _ "" & @CRLF & _ "Telefon +49 99 99999-77777 92927 Berlin" & @CRLF & _ "Fax +49 99 99999-77777 Besucheranschrift:" & @CRLF & _ "Mobil +49 992 9999977777 Lichtenberger Straße 29 a" & @CRLF & _ "" & @CRLF & _ "0171-99 99 99 99" & @CRLF & _ "" & @CRLF & _ "040 6026770 s.goetze@provin.net" & @CRLF & _ "Mobil 0170-7934869 E-Email: leglos@athanasia-coaching.de" & @CRLF & _ "" & @CRLF & _ "steffen.sprattler@consigno.net T+41 844 266 744" & @CRLF & _ "" & @CRLF & _ "mobil: +23 (0) 234 342 kiel@h-faktor.de www.h-faktor.de" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" 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