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

/
/

Test String

Code Generator

Generated Code

const regex = /\*Email:\* (?<email>.+)\n[\w\W]+>\n(?<name>.+)\n\n/; // Alternative syntax using RegExp constructor // const regex = new RegExp('\\*Email:\\* (?<email>.+)\\n[\\w\\W]+>\\n(?<name>.+)\\n\\n', '') const str = `New free subscriber to The Unstoppable Creator! *Email:* bailey11120@gmail.com *Source:* Substack Network *Recommended by:* Maya Sayvanova <https://email.mg1.substack.com/c/eJx80DHO4yAQhuHTQBeLGUhsFxQrrXwNa4Cxg2JMBNhRbr9Kmt1m_3I0X_Ho9dR4zeVt6-GqL_HZYt4ve25xiZ4-hwxW9eh7J9lCj3gbbzdAyYniNq-8c6HGYab29wvqOsi7dcM4OMZh6AGNw6sPA3BAY0YYwxicjBYVGjUoDUYBYKc7cqMH8myU6f1CvrunR1WbU8KotEL3YTbyj87nJGOdl8JfiW3lYLnZe2vPKvQvgZPA6d-1wOlZ8hI3FjhpUMaMeEn0pkul90l7Pkno6WhprvkonoX-_f8mxdLmuLTsyVE9Y6A9CqPWD-VLq4cLOVHc7ev1ku2HvEflMsdgAQxoQC1Pi38CAAD__6KuiAk> from Smarter Solopreneurs <https://email.mg1.substack.com/c/eJx8kM1qwzAQhJ_GutXsSqqdHHQolLyG2V1vHBHbCvpJ6NuX5FJ6aI_DMMzHJ1R1SfkrlMZFcrzVmPa3PdV4jkLPYOYAo5WRjQYcrR2Ow4DW6EZxnRbdNVPVeaL60yK8H8wleOf54NgzDjSD8DgwEh9BYBBiHkwMFqyHAzj0gGh71xMfBUnUgx_lTNJftmuBlaHzsC3YPzErybWXtJlYpnPWF0moualZw6XWW-ncR2dPnT3hTXNJO7cSdy3l17pzp1a3qaSWRTv3-beAHGhlzTUJMZV7nGmPnYfl-fviKI3ntFHcw-PxMPUfl61onuIcED06tM7cg_0OAAD__4MAg48> Bailey Schmidt bingusburger Also subscribes to A16Z GAMES, Adjacent Possible and 53 other Substacks <https://email.mg1.substack.com/c/eJx8kE2O4yAQhU8Du7GKgrHjBYuRRrmGVUDhoNgm4idR377lbLo33cuq96T36fPUeM3lw9buqi_p0VI-_hy5pZg8nYcMFib0k5Ns1YQ4zuOoUPJOaVtWPrhQ47BQ-0oV_L3ImwWkaVZ8iYFnj3EaZz1riE6PzgWMWiaLgAYuoJUBpXDQA7nZK_JswEw-kh9u-73C5kAY2Fc1nJiN_H3weZepLrHwm8S20llu9tbaowr9T-BV4PV7-_wYcOlYe3W9rFyEvva2LzX34lno_z8rKJY2x6VlT47qMwU6kjCwnstvktpdyDulw75eL9l-sdkrlyUFq5RRWqGWT4ufAQAA___DKoMr> View dashboard <https://email.mg1.substack.com/c/eJx8kLGOszAQhJ8Gdz_yLiaQwsXf8BpovSxgBTCyl0T39qekOV1z5Wik-T4Nk8qS8pcvVyic46kxHf-OpHGOTO9gJm875C4Y8dAh3u63G6CRneI2LnJIJpVpJP1pwba9WT2EMLUtudaxNATz3PfEyK3DO_ZNZ030aNHZ3jbgLADWTU3hzkAszrqOZ-J63R_FbsFWzu4L1G9NJX7UnHYTyzhn-Zh4zZeYza-qZ6ma_xUOFQ66ynUUTedJYRPOQpryr40Kh_MKWyxrhcOadjHZ0xYka2IKVJ5xoiNWzi5vyodarjClneLhX6-X0T-eu4rkMU4ewEED2Jinx-8AAAD__9cXe8E> To unsubscribe from these notifications, click here <https://email.mg1.substack.com/c/eJx8kM2O6yAMhZ8GdjfChpJ2weJKo75GZMBNUfNTgdNo3n6UbqarWR4dS-f7nEh4XOt3aFtsqZanlHX5t6xSbiXREXQOpsfUR80BekR_8R5Q80xlGkZeuJJwHkh-WzCns74HtD0ayCfHPvqeTMyYLdHZunhJ4L0uAQ06czYWnAHAznZ0VJTYGdenG6XuPj-amaJRzswjdAemUHp0aZ11acOt8pskSN1YT-Eu8mzK_ld4VXj9vD4ii5RlbMpeG6dDTtmvT9ema6ApcpU1UaT2KpmWopwZj433ZttiXmcqS9j3Xcsff9sa16HkAODAAlr9CvgTAAD__0nUelk`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; if ((m = regex.exec(str)) !== null) { // 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