Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m)(?<=parsable-cite=\\\")\w{2}\/\d{3}\/\d{3}`) var str = `{"billnumber": "499", "billbody": "<bill bill-stage=\"Introduced-in-Senate\" public-private=\"public\">\n <metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n <dublinCore>\n <dc:title>113 S499 IS: Patient Choice Restoration Act</dc:title>\n <dc:publisher>U.S. Senate</dc:publisher>\n <dc:date>2013-03-07</dc:date>\n <dc:format>text/xml</dc:format>\n <dc:language>EN</dc:language>\n <dc:rights>Pursuant to Title 17 Section 105 of the United States Code, this file is not subject to copyright protection and is in the public domain.</dc:rights>\n </dublinCore>\n </metadata>\n <form>\n <distribution-code display=\"yes\">II</distribution-code>\n <congress>113th CONGRESS</congress>\n <session>1st Session</session>\n <legis-num>S. 499</legis-num>\n <current-chamber>IN THE SENATE OF THE UNITED STATES</current-chamber>\n <action>\n <action-date date=\"20130307\">March 7, 2013</action-date>\n <action-desc>\n <sponsor name-id=\"S299\">Mr. Vitter</sponsor>(for himself\n\t\t\t and<cosponsor name-id=\"S355\">Mr. Cruz</cosponsor>) introduced the following\n\t\t\t bill; which was read twice and referred to the<committee-name committee-id=\"SSFI00\">Committee on\n\t\t\t Finance</committee-name>\n </action-desc>\n </action>\n <legis-type>A BILL</legis-type>\n <official-title>To repeal the Patient Protection and Affordable Care\n\t\t Act.</official-title>\n </form>\n <legis-body>\n <section id=\"id6D79D62AF466494398FF5FE90F4B4C54\" section-type=\"section-one\">\n <enum>1.</enum>\n <header>Short title</header>\n <text display-inline=\"no-display-inline\">This Act may be cited as the<quote>\n <short-title>Patient Choice Restoration\n\t\t\t Act</short-title>\n </quote>.</text>\n </section>\n <section id=\"idCD2A3EA9F06D44988B7B6592EC5A1643\" section-type=\"subsequent-section\">\n <enum>2.</enum>\n <header>Repeal</header>\n <subsection id=\"idCEB3A1D87FE64817A5F57C139C2503BA\">\n <enum>(a)</enum>\n <header>In\n\t\t\t general</header>\n <text display-inline=\"yes-display-inline\">The following Acts,\n\t\t\t and the amendments made by such Acts, are repealed:</text>\n <paragraph id=\"idF23F83A55FFE4D6BBDD8E6A089D8E9A5\">\n <enum>(1)</enum>\n <text display-inline=\"yes-display-inline\">The<cato:entity xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"law-citation\">\n <cato:entity-ref entity-type=\"act\" value=\"Patient Protection and Affordable Care Act\">Patient Protection and Affordable Care\n\t\t\t Act</cato:entity-ref>(<external-xref legal-doc=\"public-law\" parsable-cite=\"pl/111/148\">Public Law 111\u2013148</external-xref>)</cato:entity>.</text>\n </paragraph>\n <paragraph id=\"id2BD61EF1ED3E451182DDEDD02FFC6850\">\n <enum>(2)</enum>\n <text display-inline=\"yes-display-inline\">The<cato:entity xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"law-citation\">\n <cato:entity-ref entity-type=\"act\" value=\"Health Care and Education Reconciliation Act of 2010\">Health Care and Education\n\t\t\t Reconciliation Act of 2010</cato:entity-ref>(<external-xref legal-doc=\"public-law\" parsable-cite=\"pl/111/152\">Public Law 111\u2013152</external-xref>)</cato:entity>.</text>\n </paragraph>\n </subsection>\n <subsection id=\"idE7C3196B19BF4FBC9B58ED08B87DBAC3\">\n <enum>(b)</enum>\n <header>Effect of\n\t\t\t law</header>\n <text>The provisions of law amended by the Acts referred to in<cato:entity-ref xmlns:cato=\"http://namespaces.cato.org/catoxml\" entity-type=\"act\" value=\"Patient Choice Restoration Act/s:2/ss:a\" proposed=\"true\">subsection (a)</cato:entity-ref>are restored as if such Acts had never been enacted.</text>\n </subsection>\n </section>\n </legis-body>\n</bill>", "billversion": "is", "congress": "113", "billtype": "s"}` for i, match := range re.FindAllString(str, -1) { fmt.Println(match, "found at index", i) } }

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 Golang, please visit: https://golang.org/pkg/regexp/