Regular Expressions 101

Save & Share

  • Save new Regex
    ctrl+s
  • Update 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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

/
/
gm

Test String

Code Generator

Generated Code

const regex = /(?<=Full\sName\r?\n).*$/gm; // Alternative syntax using RegExp constructor // const regex = new RegExp('(?<=Full\\sName\\r?\\n).*$', 'gm') const str = ` Saturday, November 13, 2021 at 03:12:14 India Standard Time Subject: FW: [External] New Outdoor Adver=sing Date: Saturday, 13 November 2021 at 3:05:06 AM India Standard Time From:me To: ro Category: MCL:All Employees Saumil, Quote: Q-22222 Confirming a TCV of \$6,588.95 *The PO did not upload into the SFDC opportunity. Thank you, Cecil From: Upstream Date: Friday, November 12, 2021 at 2:30 PM To: DL Subject: [External] New Adver=sing Page 1 of 5New Order Buyer ID 123 Offer ID Product ID 125489 Product Code 8gvrhm11221 Dimension Pricing Page 2 of Falcon Premium Quantity 50 Price Per \$131.78 Total Price \$6588.95 Contract Value Falcon Premium Duration 12 Months Gross Contract \$6588.95 Value Marketplace Fee 0.00% Net Contract Value \$6588.95 Contract Metadata Account Number 1212121 Salesforce Opportunity nmh Quote Number Q-9090 Registration Details Company Advertising Full Name Omkar Derryberry Email Address Page 3 of om@qes.com Are You An Existing Yes AWS Account ID 121212 Phone Number 5412969684 Address 12221 bekery Road City The USA State/Province Mohan Zip/Postal Code 202020 Country In Sky Entitlements Quantity 50 Expiration 2022-11-12T20:19:43 Please contact them directly to confirm the purchase and gather any additional information. It’s time to deploy some software! Cheers! Team xyz Page 5 of 5`; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions