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
No Match

r"
"
gm

Test String

Code Generator

Generated Code

$re = '/{\'?\w+\'?\:? ?\'?\w+\/?\w+ ?\-? ?\w+ ?\w+ ?\w+\'?(\,?) ?\'?\w+\'?\:? ?\'?(\d+)?\-?(\d+)?\-?([a-z0-9A-Z/:\']+)?(\,?) ?\,?\'?\w+\'?\:? ?\'?(\w+)?\'?(\,?) ?\'?(\w+)?\'?\:? ?\'?([a-zA-Z 0-9,\\\\\.\-\;\(\)\$\:\/]+)?\'?}/m'; $str = '{\'action\': \'Inspection/Audit - No Deficiencies Noted\', \'date\': \'2004-03-15T00:00:00Z\', \'flag\': \'Green\'} {\'flag\': \'Unspecified\'} {\'flag\': \'Unspecified\'} {\'flag\': \'Unspecified\'} {\'flag\': \'Unspecified\'} {\'flag\': \'Unspecified\'} {\'action\': \'Inspection/Audit- Voluntary Action Indicated\', \'date\': \'2003-03-04T00:00:00Z\', \'flag\': \'Yellow\', \'details\': \'\'} {\'action\': \'Other\', \'date\': \'2017-06-20T00:00:00Z\', \'flag\': \'Red\', \'details\': \'June 20, 2017\\n\\nCase No. 18-079\\n\\nIt is admitted by Dr. Thorneycroft that, on November 30, 2016, upon the stipulation of the parties, the Commission issued a Consent Order finding that Dr. Thorneycroft violated Commission Rule 545-X-4-.06(6) by failing to obtain by December 31, 2015, the 50 credits of Category 1 CME required by a Consent Order of the Commision entered on January 28, 2015. Dr. Thorneycroft was reprimanded, assessed a $5,000 administrative fine (payable in annual installments), and required to complete, before June 30, 2017, 25 credits of Category 1 CME in addition to earning the 25 credits of Category 1 CME which were necessary to receive his annual registration.\\n\\nDr. Thorneycroft admits that on or about July 26, 2017, pursuant to a request from the Board, he produced evidence of only twelve (12) valid credits earned during the period, November 30, 2016 through June 30, 2017. Dr. Thorneycroft did have sufficient credits necessary for his annual registration for 2017.\\n\\n...Based upon the foregoing findings of fact and conclusions of law, it is the ORDER of the Medical Licensure Commission:\\n\\n1. That the license to practice medicine of the Respondent, IAN HALL THORNEYCROFT, M.D., license certificate number MD.15135, be, and is hereby REPRIMANDED.\\n\\n\\n\\nhttps://abme.igovsolution.com/ABMEDOCS/2018/7/0322a952c6e6427ebddaef1288e84b60732018.pdf\'} {\'action\': \'Inspection/Audit - No Deficiencies Noted\', \'date\': \'2001-02-22T00:00:00Z\', \'flag\': \'Green\'} {\'flag\': \'Unspecified\'} {\'flag\': \'Unspecified\'} {\'flag\': \'Unspecified\'} {\'action\': \'Inspection/Audit- Voluntary Action Indicated\', \'date\': \'2003-08-13T00:00:00Z\', \'flag\': \'Yellow\', \'details\': \'03-Inadequate informed consent form;\\r\\n06-Inadequate and inaccurate records;\\r\\n15-Failure to notify IRB of changes, failure to submit progress reports;\\r\\n16-Failure to report adverse drug reactions\'} {\'flag\': \'Unspecified\'} {\'action\': \'Inspection/Audit - No Deficiencies Noted\', \'date\': \'2010-06-16T00:00:00Z\', \'flag\': \'Green\', \'details\': \'\'} {\'action\': \'Inspection/Audit - No Deficiencies Noted\', \'date\': \'2010-06-28T00:00:00Z\', \'flag\': \'Green\', \'details\': \'No deficiencies noted\'} {\'action\': \'Inspection/Audit - No Deficiencies Noted\', \'date\': \'2005-12-13T00:00:00Z\', \'flag\': \'Green\'} {\'action\': \'Inspection/Audit- Voluntary Action Indicated\', \'date\': \'2003-08-13T00:00:00Z\', \'flag\': \'Yellow\', \'details\': \'03-Inadequate informed consent form;\\r\\n06-Inadequate and inaccurate records;\\r\\n15-Failure to notify IRB of changes, failure to submit progress reports;\\r\\n16-Failure to report adverse drug reactions\'} {\'action\': \'Inspection/Audit - No Deficiencies Noted\', \'date\': \'2005-12-13T00:00:00Z\', \'flag\': \'Green\'} '; 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