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

Substitution

Processing...

Code Generator

Generated Code

re = /^"[\w ]+ \w*. \w*.\d*.\nTX \d*\n\((\d*.+), (\-\d*.\d*)\)"/m str = 'Location "3415 Sweetgum Trc TX 78713 (30.459330, -97.824449)" "4420 Dovemeadow Dr TX 78744 (30.188962, -97.750896)" "7400 Espira Drive TX 78739 (30.184748, -97.917591)" "9321 Bavaria Ln. TX 78749 (30.202255, -97.874029)" "11504 Murcia Dr TX 78759 (30.409891, -97.738812)" "13101 Winding Creek Rd TX 78736 (30.240521, -97.992054)" "7128 Mumruffin Ln TX 78754 (30.34478, -97.61014)" "2815 Oak Ridge Dr TX 78669 (30.368907, -98.036141)" "903 Vincent Place TX 78660 (30.443807, -97.651466)" "4704 Sunridge Ct TX 78741 (30.219579, -97.727328)" "5931 Cape Coral Dr TX 78746 (30.278937, -97.836048)" "2815 Oak Ridge Dr TX 78669 (30.368907, -98.036141)" "8701 Bluffstone Cv. #2202 TX 78759 (30.389267, -97.766356)" "20608 Ed Acklin Rd TX 78653 (30.27633, -97.49126)" "11824 Morning View Dr TX 78617 (30.15396, -97.647841)" "7600 Bloomfield Ave TX 78745 (30.204901, -97.828946)" "14329 Teacup Ln TX 78660 (30.418056, -97.636821)" "4809 Clear View Dr TX 78725 (30.244119, -97.581393)" "11511 Catalonia Dr TX 78759 (30.410848, -97.739218)" "18300 Belfry Pass TX 78653 (30.31697, -97.53009)" "705 Texas St TX 78705 (33.222247, -97.124425)" "12904 Schleicher Trl TX 78732 (30.381982, -97.893992)" "11929 Rosethorn Dr TX 78758 (30.400166, -97.700383)" "2520 East 3rd St TX 78702 (30.255743, -97.714709)" "11305 Cezanne St TX 78726 (30.44945, -97.820962)" "5336 Magdelena Dr TX 78704 (30.257704, -97.833415)" "2401 Cecil Dr TX 78744 (30.165036, -97.773046)" "5205 Bantom Woods Bnd. TX 78721 (30.273542, -97.631229)" "2401 Cecil Dr TX 78744 (30.165036, -97.773046)" "2718 Jorwoods Dr TX 78745 (30.201176, -97.821866)" "7200 Reaburn St. TX 78749 (30.213462, -97.836052)" "6204 Skahan Ln. TX 78739 (30.187183, -97.892496)" "905 Tudor House Road TX 78660 (30.421455, -97.640466)" "1205 Quail Park Dr TX 78758 (30.365438, -97.706068)" "6204 Skahan Ln. TX 78739 (30.187183, -97.892496)" "7002 Montana St TX 78741 (30.228851, -97.691627)" "3703 Grayson Ln TX 78722 (30.288239, -97.708983)" "1302 Canyon Edge Dr TX 78733 (30.336045, -97.864337)" "11824 Morning View Dr TX 78617 (30.15396, -97.647841)" "4707 Carsonhill Dr TX 78723 (30.288236, -97.676578)" "1411 Justin Ln TX 78757 (30.341012, -97.727488)" "6319 Parliament Dr. #A TX 78724 (30.286891, -97.658975)" "5205 Bantom Woods Bnd. TX 78721 (30.273542, -97.631229)" "1304 Neans Dr. TX 78758 (30.376535, -97.700762)" "7701 Callbram Ln TX 78736 (30.233294, -97.892511)" "14329 Teacup Ln TX 78660 (30.418056, -97.636821)" "14028 Lakeview Dr TX 78732 (30.414976, -97.89322)" "5107 Saddle Cir. TX 78727 (30.422686, -97.733608)" "1302 Lipan Trl TX 78733 (30.33921, -97.870528)" "11511 Catalonia Dr TX 78759 (30.410848, -97.739218)" "14707 Reynero Ln. #E TX 78617 (30.089307, -97.64347)" "3705 Robinson Ave. TX 78722 (30.293536, -97.719088)" "412 Summer Alcove Way TX 78732 (30.340744, -97.912968)" "7200 Reaburn St. TX 78749 (30.213462, -97.836052)" "7201 Levander Loop TX 78702 (30.251079, -97.691727)" "2401 Emmett Pkwy TX 78728 (30.452414, -97.677731)" "6319 Parliament Dr. #A TX 78724 (30.286891, -97.658975)" "1910 Haskell St. TX 78722 (30.252278, -97.725848)" "2813 Tradewind Dr. TX 78669 (30.362084, -98.024851)" "7916 Adelaide Dr TX 78739 (30.19158, -97.919402)" "903 Vincent Place TX 78660 (30.443807, -97.651466)" "4812 Candletree Ln TX 78744 (30.188398, -97.74624)" "6604 Jamaica Ct TX 78757 (30.347375, -97.748886)"' subst = '\\1\\t\\2' result = str.gsub(re, subst) # Print the result of the substitution puts 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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html