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

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

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php