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

/
/
g

Test String

Code Generator

Generated Code

$re = '/(B\d{2}\w{7})/'; $str = ' User account Research Bestseller Watchlist Monitoring User List Dashboard Log out Feedback Add product(s) Filters Marketplace Category Title contains Title contains Tag equals Tag equals Brand equals Brand equals Seller equals Seller equals Buybox Buybox Amazon FBA FBM Per page Compare Total products: 20 Previous 1 Next Fav. Image MP Title ASIN Brand Price Sales rank Category Buybox # Sellers # Reviews Rating LQI Options Sternenlichter Sternenhimmel 500 Leuchtpunkte B019HAY3C4 Sternenlichter € 12.99 128075 Küche & Haushalt FBA FRIES Digital 1 49 4.1 90 Bentgo - Bento Box / Lunchbox inkl. Besteck (Lila) B00B78W282 Bentgo € 17.90 10093 Küche & Haushalt FBA use-again 3 99 4.3 75 Bentgo - Bento Box / Lunchbox inkl. Besteck (Grün) B00B78WO3U Bentgo € 17.90 11190 Küche & Haushalt FBA use-again 1 99 4.3 75 Bentgo - Bento Box / Lunchbox inkl. Besteck (Blau) B00B78T8U2 Bentgo € 17.90 10560 Küche & Haushalt FBA use-again 2 99 4.3 75 Bentgo - Bento Box / Lunchbox inkl. Besteck (Grau) B00B78UBO4 Bentgo € 17.90 2658 Küche & Haushalt FBA use-again 2 99 4.3 75 Emsa 516943 3-teiliges Frischhaltedosenset, 1 Liter, Transparent/Blau, Clip & Close B004QGXKRO Emsa € 11.79 433 Küche & Haushalt Amazon 40 297 4.6 90 Meal Prep Haven Lebensmittelbehälter mit 2 Fächern und Deckeln für die Portionskontrolle, ... B011SUKOHE Meal Prep Haven box 463636 Küche & Haushalt 1 25 Mikrowelle und spülmaschinenfest stapelbar Mahlzeit Prep Kunststoff Lebensmittel Behälter ... B0195971NU Superior box € 16.49 15941 Küche & Haushalt FBA K Master 1 40 3.9 65 Mikrowelle und spülmaschinenfest stapelbar Mahlzeit Prep Kunststoff Lebensmittel Behälter ... B01BCNFT3Q Superior box € 16.89 11542 Küche & Haushalt FBA K Master 1 40 3.9 65 Mikrowelle und spülmaschinenfest stapelbar Mahlzeit Prep Kunststoff Lebensmittel Behälter ... B017KNFDOM Superior box € 16.89 3630 Küche & Haushalt FBA K Master 2 40 3.9 55 Meal Prep Haven Lebensmittelbehälter mit 3 Fächern und Deckeln für die Portionskontrolle, ... B011SY4P9I Meal Prep Haven box 46144 Küche & Haushalt 1 4 3.3 40 XL Silikon Backmatte von Cookin´Active, BPA frei, Platinum Silikon, Lebensmittelecht, Anti ... B01AR1L0FU Cookin\'Active € 17.99 3234 Küche & Haushalt FBA Flatland Trading 1 35 5 90 WENKO 4374120100 Wäschesortierer Air - 6 breite Fächer, 100 % Polypropylen, 30 x 120 x 30 ... B0034KYP1I Wenko hängeregal € 9.99 2669 Küche & Haushalt Amazon 5 57 4.2 65 WENKO 64004100 Multi-Organizer Butterfly - 10 Fächer, 100% Polypropylen, 15 x 127 x 30 cm, ... B00URLQRMW Wenko hängeregal € 11.99 451701 Küche & Haushalt Amazon 4 45 Metaltex 751016 Hängeregal, 10 Fächer, 20 x 29 x 120 cm B0098UXD3O Metaltex hängeregal € 14.07 357099 Küche & Haushalt Amazon 1 20 Chintz, Vintage-Stil gemustert, 10 Taschen für Schuh-Aufbewahrung B00KD875RU Lloyd Pascal hängeregal € 9.49 1540117 Küche & Haushalt FBA ramsdensdirect 2 20 WENKO 4372030100 Multiorganizer Comfort - 10 Fächer, Kunststoff - PEVA, 15 x 122 x 30 cm, ... B001AI590W Wenko hängeregal € 9.99 34405 Küche & Haushalt Amazon 3 11 3.9 20 Delete selected products Previous 1 Next Copyright © 2016 AMALYTIX.COM'; 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