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)(?<=\+)[0-9\-]*" Local $sString = "/+1-541-754-3010 156 Alphand_St. <J Steeve>" & @CRLF & _ " 133, Green, Rd. <E Kustur> NY-56423 ;+1-541-914-3010" & @CRLF & _ "+1-541-984-3012 <P Reed> /PO Box 530; Pollocksville, NC-28573" & @CRLF & _ " :+1-321-512-2222 <Paul Dive> Sequoia Alley PQ-67209" & @CRLF & _ "+1-741-984-3090 <Peter Reedgrave> _Chicago" & @CRLF & _ " :+1-921-333-2222 <Anna Stevens> Haramburu_Street AA-67209" & @CRLF & _ "+1-111-544-8973 <Peter Pan> LA" & @CRLF & _ " +1-921-512-2222 <Wilfrid Stevens> Wild Street AA-67209" & @CRLF & _ "<Peter Gone> LA ?+1-121-544-8974 " & @CRLF & _ " <R Steell> Quora Street AB-47209 +1-481-512-2222" & @CRLF & _ "<Arthur Clarke> San Antonio $+1-121-504-8974 TT-45120" & @CRLF & _ " <Ray Chandler> Teliman Pk. !+1-681-512-2222! AB-47209," & @CRLF & _ "<Sophia Loren> +1-421-674-8974 Bern TP-46017" & @CRLF & _ " <Peter O'Brien> High Street +1-908-512-2222; CC-47209" & @CRLF & _ "<Anastasia> +48-421-674-8974 Via Quirinal Roma" & @CRLF & _ " <P Salinger> Main Street, +1-098-512-2222, Denver" & @CRLF & _ "<C Powel> *+19-421-674-8974 Chateau des Fosses Strasbourg F-68000" & @CRLF & _ " <Bernard Deltheil> +1-498-512-2222; Mount Av. Eldorado" & @CRLF & _ "+1-099-500-8000 <Peter Crush> Labrador Bd." & @CRLF & _ " +1-931-512-4855 <William Saurin> Bison Street CQ-23071" & @CRLF & _ "<P Salinge> Main Street, +1-098-512-2222, Denve" & @CRLF & _ "<P Salinge> Main Street, +1-098-512-2222, Denve" & @CRLF & _ "/+5-541-754-3010 156 Alphandria_Street. <Jr Part>" & @CRLF & _ " 1333, Green, Road <F Fulgur> NW-46423 ;+6-541-914-3010!" & @CRLF & _ "+5-541-984-3012 <Peter Reeves> /PO Box 5300; Albertville, SC-28573" & @CRLF & _ " :+5-321-512-2222 <Paulo Divino> Boulder Alley ZQ-87209" & @CRLF & _ "+3-741-984-3090 <F Flanaghan> _Chicago Av." & @CRLF & _ " :+3-921-333-2222 <Roland Scorsini> Bellevue_Street DA-67209" & @CRLF & _ "+8-111-544-8973 <Laurence Pantow> SA" & @CRLF & _ " +8-921-512-2222 <Raymond Stevenson> Joly Street EE-67209" & @CRLF & _ "<John Freeland> Mantow ?+2-121-544-8974 " & @CRLF & _ " <Robert Mitch> Eleonore Street QB-87209 +2-481-512-2222?" & @CRLF & _ "<Arthur Paternos> San Antonio $+7-121-504-8974 TT-45121" & @CRLF & _ " <Ray Charles> Stevenson Pk. !+7-681-512-2222! CB-47209," & @CRLF & _ "<JP Gorce> +9-421-674-8974 New-Bern TP-16017" & @CRLF & _ " <P McDon> Revolution Street +2-908-512-2222; PP-47209" & @CRLF & _ "<Elizabeth Corber> +8-421-674-8974 Via Papa Roma" & @CRLF & _ " <C Saborn> Main Street, +15-098-512-2222, Boulder" & @CRLF & _ "<Colin Marshall> *+9-421-674-8974 Edinburgh UK" & @CRLF & _ " <Bernard Povit> +3-498-512-2222; Hill Av. Cameron" & @CRLF & _ "+12-099-500-8000 <Pete Highman> Ontario Bd." & @CRLF & _ " +8-931-512-4855 <W Mount> Oxford Street CQ-23071" & @CRLF & _ "<Donald Drinkaw> Moon Street, +3-098-512-2222, Peterville" 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