Regular Expressions 101

Save & Share

  • Regex Version: ver. 4
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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 = /^\|([^\|]*\|){2}[^\s\|]/m str = '| 17255|Sumner Highlands |4507 Sangamore Rd |Bethesda |20816 |177569|-77.118822124|38.948172261|2023-04-04T10:00:00|3|1| 125| 31| 0.48| 0.88| 21| 0| 0|compliant| | 17547|The Birches |1532 Heather Hollow Cir |Silver Spring |20904 |178105|-76.980971525|39.040723373|2023-04-11T10:22:48|3|1| 227| 49| 0.42| 0.34| 34| 0| 0|compliant| | 17772|Glenville Road, 8812 |8812 Glenville Rd |Silver Spring |20901 |177597|-76.997005506|39.000266646|2023-05-08T12:41:39|3|1| 4| 6| 4.83| 1.92| 0|0.33| 0|troubled | |151598|Westchester West Apartments |3020 HEWITT AVE |SILVER SPRING |20906 |178118|-77.064392607|39.079760287|2023-06-29T10:34:44|2|1| 345| 64| 2.64| 1.17| 22|0.06| 0|at-risk | |122536|Inigo\'s Crossing |5405 TUCKERMAN LN |ROCKVILLE |20852 |177638|-77.108192429|39.029109621|2023-03-30T13:53:00|3|0| 473| 109| 0.95| 1.33| 52| 0|0.03|compliant| |148419|8805 PLYMOUTH ST |8805 PLYMOUTH ST |SILVER SPRING |20901 |176723| -77.00691082| 39.00078819|2023-04-04T11:14:27|3|1| 7| 7| 0.57| 0.85| 4| 0| 0|compliant| |117270|Fairland Crossing |14001 CASTLE BLVD |SILVER SPRING |20904 |177507|-76.940498016|39.084672257|2023-06-21T10:40:07|1|1| 534| 528| 3.1| 1.74| 75| 0.1|0.02|troubled | | 17951|Prospect Street, 908 |908 PROSPECT ST |TAKOMA PARK |20912 |176677|-76.998919873|38.989544716|2023-04-04T10:29:06|1|1| 4| 4| 1.25| 0.8| 2| 0| 0|compliant| | 18024|Flower Avenue, 8511 |8511 FLOWER AVE |TAKOMA PARK |20912 |157672|-77.002600204|38.996090439|2019-09-16T09:54:44|2|0| 2| 4| 1.25| 1.35| 1| 0| 0|compliant| | 62678|Metro Pointe Apartments |11175 GEORGIA AVE |SILVER SPRING |20902 |178094|-77.050482435|39.038547192|2023-04-26T09:57:26|3|1| 173| 44| 0.27| 0.37| 36| 0| 0|compliant| |150630|Maven at Wheaton |10914 GEORGIA AVE |SILVER SPRING |20902 |177513|-77.050201943|39.035227779|2023-03-31T10:32:38|3|1| 232| 62| 0.38| 0.15| 57|0.03| 0|compliant| | 17292|Summit Hills |8484 16Th St |Silver Spring |20910 |178095| 0| 0|2023-05-23T10:28:29|3|1| 112| 269| 2.8| 1.88| 30|0.03| 0|troubled | | 17632|The Point At Germantown |2 Observation Ct |Germantown |20876 |175575| -77.24749447|39.192139826|2023-03-29T10:07:12|2|1| 218| 63| 0.85| 1.11| 28|0.03| 0|compliant| | 17200|Seneca Ridge |19568 Scenery Dr |Germantown |20876 |177536|-77.234887494|39.176871982|2023-04-13T12:36:00|3|1| 71| 58| 1.62| 1.13| 26|0.05| 0|compliant| | 62427|The Veridian At Silver Spring Metro |1133 East West Hwy |Silver Spring |20910 |178097|-77.027783253|38.989346504|2023-06-15T13:45:17|3|1| 457| 110| 0.54| 0.72| 68| 0| 0|compliant| | 88897|Avery Park Apartments |1801 Hampshire Green Ln |Silver Spring |20903 |178089|-76.973864306|39.015611161|2023-06-08T12:37:48|1|1| 294| 95| 1.75| 1.63| 10|0.07|0.01|at-risk | | 17369|Schrider Street, 8115 |8115 Schrider St |Silver Spring |20910 |178075|-77.014090876|38.991809103|2023-04-18T09:53:01|2|1| 9| 11| 3.72| 1.67| 2|0.27| 0|troubled | | 63144|Archstone Wisconsin Place |4440 Willard Ave |Chevy Chase |20815 |178103|-77.087527525|38.961768579|2023-05-25T12:15:18|3|1| 432| 102| 0.79| 2.39| 10| 0| 0|at-risk | | 17493|Kennebec Avenue, 811 |811 Kennebec Ave |Takoma Park |20912 |177580|-76.999838124|38.990228425|2023-07-14T08:44:00|3|1| 1| 1| 1| 1| 0| 0| 0|compliant| |106762|Cider Mill |18205 LOST KNIFE CIR |MONTGOMERY VILLAGE|20886 |177646|-77.203234912|39.157177534|2023-06-06T11:04:03|3|0| 861| 842| 3.56| 1.8| 86|0.13|0.05|troubled |' subst = '*' 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