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)^"(.*)\n([\w ]+)(\d*)\n\(([\d\.]+), ([\d\-\.]+)\)"" Local $sString = "Location" & @CRLF & _ ""11305 Cezanne St" & @CRLF & _ "78726" & @CRLF & _ "(30.44945, -97.820962)"" & @CRLF & _ ""12904 Schleicher Trl" & @CRLF & _ "78732" & @CRLF & _ "(30.381982, -97.893992)"" & @CRLF & _ ""11511 Catalonia Dr" & @CRLF & _ "78759" & @CRLF & _ "(30.410825, -97.739233)"" & @CRLF & _ ""11511 Catalonia Dr" & @CRLF & _ "78759" & @CRLF & _ "(30.410825, -97.739233)"" & @CRLF & _ ""4809 Clear View Dr" & @CRLF & _ "78725" & @CRLF & _ "(30.244094, -97.581411)"" & @CRLF & _ ""4809 Clear View Dr" & @CRLF & _ "78725" & @CRLF & _ "(30.244094, -97.581411)"" & @CRLF & _ ""4809 Clear View Dr" & @CRLF & _ "78725" & @CRLF & _ "(30.244094, -97.581411)"" & @CRLF & _ ""13101 Winding Creek Rd" & @CRLF & _ "78736" & @CRLF & _ "(30.240521, -97.992054)"" & @CRLF & _ ""705 Texas St" & @CRLF & _ "78705" & @CRLF & _ "(30.296976, -97.728619)"" & @CRLF & _ ""2401 Cecil Dr" & @CRLF & _ "78744" & @CRLF & _ "(30.165036, -97.773046)"" & @CRLF & _ ""2401 Cecil Dr" & @CRLF & _ "78744" & @CRLF & _ "(30.165036, -97.773046)"" & @CRLF & _ ""905 Tudor House Road" & @CRLF & _ "78660" & @CRLF & _ "(30.421455, -97.640466)"" & @CRLF & _ ""2718 Jorwoods Dr" & @CRLF & _ "78745" & @CRLF & _ "(30.201192, -97.8219)"" & @CRLF & _ ""1411 Justin Ln" & @CRLF & _ "78757" & @CRLF & _ "(30.341012, -97.727488)"" & @CRLF & _ ""2520 East 3rd St" & @CRLF & _ "78702" & @CRLF & _ "(30.255757, -97.714748)"" & @CRLF & _ ""4420 Dovemeadow Dr" & @CRLF & _ "78744" & @CRLF & _ "(30.188978, -97.750916)"" & @CRLF & _ ""903 Vincent Place" & @CRLF & _ "78660" & @CRLF & _ "(30.443792, -97.651432)"" & @CRLF & _ ""903 Vincent Place" & @CRLF & _ "78660" & @CRLF & _ "(30.443792, -97.651432)"" & @CRLF & _ ""6501 Corpus Christi Dr" & @CRLF & _ "78729" & @CRLF & _ "(30.446164, -97.745231)"" & @CRLF & _ ""14329 Teacup Ln" & @CRLF & _ "78660" & @CRLF & _ "(30.418031, -97.636836)"" & @CRLF & _ ""14329 Teacup Ln" & @CRLF & _ "78660" & @CRLF & _ "(30.418031, -97.636836)"" & @CRLF & _ ""9211 Lauralan Dr" & @CRLF & _ "78736" & @CRLF & _ "(30.244022, -97.90871)"" & @CRLF & _ ""4812 Candletree Ln" & @CRLF & _ "78744" & @CRLF & _ "(30.188373, -97.746254)"" & @CRLF & _ ""15109 Holly Ln" & @CRLF & _ "78734" & @CRLF & _ "(30.366232, -97.94599)"" & @CRLF & _ ""20608 Ed Acklin Rd" & @CRLF & _ "78653" & @CRLF & _ "(30.27638, -97.491359)"" & @CRLF & _ ""7600 Bloomfield Ave" & @CRLF & _ "78745" & @CRLF & _ "(30.204975, -97.828903)"" & @CRLF & _ ""2815 Rockridge Dr" & @CRLF & _ "78744" & @CRLF & _ "(30.182879, -97.753569)"" & @CRLF & _ ""1712 Whitney Way" & @CRLF & _ "78741" & @CRLF & _ "(30.230474, -97.710957)"" & @CRLF & _ ""1709 Shadowview Dr" & @CRLF & _ "78758" & @CRLF & _ "(30.410606, -97.690225)"" & @CRLF & _ ""1302 Lipan Trl" & @CRLF & _ "78733" & @CRLF & _ "(30.339241, -97.870507)"" & @CRLF & _ ""5336 Magdelena Dr" & @CRLF & _ "78704" & @CRLF & _ "(30.257628, -97.833678)"" & @CRLF & _ ""1302 Canyon Edge Dr" & @CRLF & _ "78733" & @CRLF & _ "(30.336086, -97.864308)"" & @CRLF & _ ""2401 Emmett Pkwy" & @CRLF & _ "78728" & @CRLF & _ "(30.452399, -97.6777)"" & @CRLF & _ ""5931 Cape Coral Dr" & @CRLF & _ "78746" & @CRLF & _ "(30.278948, -97.836075)"" & @CRLF & _ ""11929 Rosethorn Dr" & @CRLF & _ "78758" & @CRLF & _ "(30.400145, -97.700419)"" & @CRLF & _ ""11504 Murcia Dr" & @CRLF & _ "78759" & @CRLF & _ "(30.40992, -97.738795)"" & @CRLF & _ ""7002 Montana St" & @CRLF & _ "78741" & @CRLF & _ "(30.22887, -97.691651)"" & @CRLF & _ ""3703 Grayson Ln" & @CRLF & _ "78722" & @CRLF & _ "(30.288216, -97.708994)"" & @CRLF & _ ""1205 Quail Park Dr" & @CRLF & _ "78758" & @CRLF & _ "(30.36542, -97.706031)"" & @CRLF & _ ""11824 Morning View Dr" & @CRLF & _ "78617" & @CRLF & _ "(30.15393, -97.647847)"" & @CRLF & _ ""11824 Morning View Dr" & @CRLF & _ "78617" & @CRLF & _ "(30.15393, -97.647847)"" & @CRLF & _ ""7400 Espina Drive" & @CRLF & _ "78739" & @CRLF & _ "(30.184836, -97.917651)"" & @CRLF & _ ""4707 Carsonhill Dr" & @CRLF & _ "78723" & @CRLF & _ "(30.288232, -97.676602)"" & @CRLF & _ ""14028 Lakeview Dr" & @CRLF & _ "78732" & @CRLF & _ "(30.414996, -97.893207)"" & @CRLF & _ ""18300 Belfry Pass" & @CRLF & _ "78653" & @CRLF & _ "(30.316997, -97.530072)"" & @CRLF & _ ""7916 Adelaide Dr" & @CRLF & _ "78739" & @CRLF & _ "(30.19158, -97.919402)"" & @CRLF & _ ""1512 Miss Allisons Way" & @CRLF & _ "78660" & @CRLF & _ "(30.447836, -97.65996)"" & @CRLF & _ ""911 Peggotty Pl" & @CRLF & _ "78753" & @CRLF & _ "(30.387673, -97.66531)"" & @CRLF & _ ""7005 Bright Star Ln" & @CRLF & _ "78736" & @CRLF & _ "(30.249735, -97.908418)"" & @CRLF & _ ""2815 Oak Ridge Dr" & @CRLF & _ "78669" & @CRLF & _ "(30.36881, -98.036181)"" & @CRLF & _ ""2815 Oak Ridge Dr" & @CRLF & _ "78669" & @CRLF & _ "(30.36881, -98.036181)"" & @CRLF & _ ""4704 Sunridge Ct" & @CRLF & _ "78741" & @CRLF & _ "(30.219579, -97.727328)"" & @CRLF & _ ""7128 Mumruffin Ln" & @CRLF & _ "78754" & @CRLF & _ "(30.344789, -97.610169)"" & @CRLF & _ ""7701 Callbram Ln" & @CRLF & _ "78736" & @CRLF & _ "(30.233262, -97.89253)"" & @CRLF & _ ""6604 Jamaica Ct" & @CRLF & _ "78757" & @CRLF & _ "(30.347375, -97.748886)"" & @CRLF & _ ""3415 Sweetgum" & @CRLF & _ "Trc 78713" & @CRLF & _ "(30.459228, -97.824468)"" & @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