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

/
/
g

Test String

Code Generator

Generated Code

$re = '/USD \K[^:]*(?= Counter-Strike:)/'; $str = '13,216 Starting at: $2.03 USD Clutch Case Counter-Strike: Global Offensive 758 Starting at: $2.55 USD Clutch Case Key Counter-Strike: Global Offensive 1,048 Starting at: $2.55 USD Spectrum 2 Case Key Counter-Strike: Global Offensive 1,028 Starting at: $2.60 USD Spectrum Case Key Counter-Strike: Global Offensive 1,421 Starting at: $7.76 USD AK-47 | Redline (Field-Tested) Counter-Strike: Global Offensive 206,745 Starting at: $0.29 USD Boston 2018 Attending Legends Autograph Capsule Counter-Strike: Global Offensive 461 Starting at: $2.56 USD Glove Case Key Counter-Strike: Global Offensive 323,020 Starting at: $0.30 USD Boston 2018 Returning Challengers Autograph Capsule Counter-Strike: Global Offensive 0 Starting at: $12.01 USD AK-47 | Frontside Misty (Field-Tested) Counter-Strike: Global Offensive 615 Starting at: $2.55 USD Gamma 2 Case Key Counter-Strike: Global Offensive 636 Starting at: $2.57 USD Gamma Case Key Counter-Strike: Global Offensive 1,017 Starting at: $1.45 USD AK-47 | Elite Build (Field-Tested) Counter-Strike: Global Offensive 863 Starting at: $1.77 USD AK-47 | Elite Build (Minimal Wear) Counter-Strike: Global Offensive 233 Starting at: $11.04 USD M4A4 | Desolate Space (Field-Tested) Counter-Strike: Global Offensive 183 Starting at: $39.85 USD AWP | Asiimov (Field-Tested) Counter-Strike: Global Offensive 1,237 Starting at: $2.55 USD Operation Hydra Case Key Counter-Strike: Global Offensive 1,034 Starting at: $1.50 USD AWP | Worm God (Minimal Wear) Counter-Strike: Global Offensive 716 Starting at: $2.21 USD AWP | Phobos (Minimal Wear) Counter-Strike: Global Offensive 102 Starting at: $38.14 USD AWP | Hyper Beast (Minimal Wear) Counter-Strike: Global Offensive 435 Starting at: $10.32 USD AWP | Fever Dream (Minimal Wear) Counter-Strike: Global Offensive 20 Starting at: $14.87 USD USP-S | Cortex (Field-Tested) Counter-Strike: Global Offensive 383 Starting at: $3.17 USD M4A4 | Evil Daimyo (Minimal Wear) Counter-Strike: Global Offensive 45 Starting at: $28.58 USD AWP | Mortis (Field-Tested) Counter-Strike: Global Offensive 240,104 Starting at: $0.05 USD Spectrum 2 Case Counter-Strike: Global Offensive 817 Starting at: $6.00 USD M4A1-S | Decimator (Field-Tested) Counter-Strike: Global Offensive 45 Starting at: $36.38 USD AWP | Mortis (Minimal Wear) Counter-Strike: Global Offensive 73 Starting at: $52.99 USD AK-47 | Bloodsport (Minimal Wear) Counter-Strike: Global Offensive 982 Starting at: $1.41 USD AWP | Worm God (Field-Tested) Counter-Strike: Global Offensive 46,075 Starting at: $0.03 USD AUG | Contractor (Field-Tested) Counter-Strike: Global Offensive 728 Starting at: $1.12 USD AK-47 | Elite Build (Well-Worn) Counter-Strike: Global Offensive 8,412 Starting at: $1.61 USD Operation Hydra Case Counter-Strike: Global Offensive 443 Starting at: $8.67 USD AWP | Fever Dream (Field-Tested) Counter-Strike: Global Offensive 354 Starting at: $3.10 USD USP-S | Cyrex (Minimal Wear) Counter-Strike: Global Offensive 286 Starting at: $2.02 USD USP-S | Cyrex (Field-Tested) Counter-Strike: Global Offensive 253 Starting at: $30.84 USD AWP | Asiimov (Battle-Scarred) Counter-Strike: Global Offensive 247 Starting at: $11.59 USD AWP | Man-o\'-war (Minimal Wear) Counter-Strike: Global Offensive 948 Starting at: $2.04 USD Name Tag Counter-Strike: Global Offensive 415 Starting at: $3.70 USD M4A1-S | Leaded Glass (Field-Tested) Counter-Strike: Global Offensive 135 Starting at: $19.20 USD AK-47 | Aquamarine Revenge (Field-Tested) Counter-Strike: Global Offensive 117 Starting at: $33.52 USD AWP | Asiimov (Well-Worn) Counter-Strike: Global Offensive 301 Starting at: $3.53 USD AWP | Sun in Leo (Minimal Wear) Counter-Strike: Global Offensive 249 Starting at: $3.69 USD Glock-18 | Water Elemental (Field-Tested) Counter-Strike: Global Offensive 241 Starting at: $7.50 USD AK-47 | Orbit Mk01 (Minimal Wear) Counter-Strike: Global Offensive 28 Starting at: $54.62 USD AWP | Mortis (Factory New) Counter-Strike: Global Offensive 402 Starting at: $2.49 USD M4A4 | Evil Daimyo (Field-Tested) Counter-Strike: Global Offensive 815 Starting at: $2.04 USD AWP | Worm God (Factory New) Counter-Strike: Global Offensive 430 Starting at: $2.11 USD AWP | Phobos (Field-Tested) Counter-Strike: Global Offensive 1,505 Starting at: $0.99 USD AWP | Pit Viper (Field-Tested) Counter-Strike: Global Offensive 1,244 Starting at: $10.43 USD Operation Bravo Case Counter-Strike: Global Offensive 774 Starting at: $2.58 USD Operation Phoenix Case Key Counter-Strike: Global Offensive 314 Starting at: $1.95 USD AK-47 | Emerald Pinstripe (Field-Tested) Counter-Strike: Global Offensive 322 Starting at: $6.76 USD AK-47 | Orbit Mk01 (Field-Tested) Counter-Strike: Global Offensive 260 Starting at: $8.32 USD M4A1-S | Hyper Beast (Field-Tested) Counter-Strike: Global Offensive 250 Starting at: $2.23 USD AWP | Sun in Leo (Field-Tested) Counter-Strike: Global Offensive 197 Starting at: $6.56 USD M4A4 | 龍王 (Dragon King) (Field-Tested) Counter-Strike: Global Offensive 0 Starting at: $13.63 USD AWP | Redline (Field-Tested) Counter-Strike: Global Offensive 162 Starting at: $22.46 USD AK-47 | Neon Revolution (Field-Tested) Counter-Strike: Global Offensive 407 Starting at: $2.56 USD Shadow Case Key Counter-Strike: Global Offensive 901 Starting at: $2.56 USD Chroma 2 Case Key Counter-Strike: Global Offensive 9,672 Starting at: $0.80 USD Huntsman Weapon Case Counter-Strike: Global Offensive 243 Starting at: $3.99 USD StatTrak™ AK-47 | Elite Build (Well-Worn) Counter-Strike: Global Offensive 107 Starting at: $3.56 USD Glock-18 | Moonrise (Field-Tested) Counter-Strike: Global Offensive 122 Starting at: $15.33 USD M4A4 | Desolate Space (Minimal Wear) Counter-Strike: Global Offensive 140 Starting at: $9.61 USD M4A4 | Desolate Space (Well-Worn) Counter-Strike: Global Offensive 594 Starting at: $1.33 USD AWP | Pit Viper (Minimal Wear) Counter-Strike: Global Offensive 149 Starting at: $2.61 USD Operation Breakout Case Key Counter-Strike: Global Offensive 270 Starting at: $4.99 USD Glock-18 | Water Elemental (Minimal Wear) Counter-Strike: Global Offensive 244 Starting at: $4.83 USD AWP | Elite Build (Field-Tested) Counter-Strike: Global Offensive 129 Starting at: $15.58 USD M4A1-S | Hyper Beast (Minimal Wear) Counter-Strike: Global Offensive 0 Starting at: $3.16 USD Desert Eagle | Conspiracy (Minimal Wear) Counter-Strike: Global Offensive 347 Starting at: $7.96 USD M4A1-S | Decimator (Minimal Wear) Counter-Strike: Global Offensive 350 Starting at: $1.58 USD USP-S | Guardian (Factory New) Counter-Strike: Global Offensive 124 Starting at: $14.73 USD AK-47 | Point Disarray (Field-Tested) Counter-Strike: Global Offensive 837 Starting at: $0.95 USD M4A1-S | Flashback (Field-Tested) Counter-Strike: Global Offensive 265 Starting at: $1.27 USD USP-S | Blueprint (Field-Tested) Counter-Strike: Global Offensive 272 Starting at: $3.82 USD M4A4 | Griffin (Minimal Wear) Counter-Strike: Global Offensive 232 Starting at: $2.59 USD Operation Wildfire Case Key Counter-Strike: Global Offensive 5,354 Starting at: $0.19 USD AK-47 | Safari Mesh (Field-Tested) Counter-Strike: Global Offensive 455 Starting at: $2.58 USD Falchion Case Key Counter-Strike: Global Offensive 107 Starting at: $29.50 USD AK-47 | Vulcan (Field-Tested) Counter-Strike: Global Offensive 0 Starting at: $18.36 USD AWP | Redline (Minimal Wear) Counter-Strike: Global Offensive 778 Starting at: $1.27 USD Five-SeveN | Monkey Business (Field-Tested) Counter-Strike: Global Offensive 527 Starting at: $1.24 USD AK-47 | Elite Build (Battle-Scarred) Counter-Strike: Global Offensive 433 Starting at: $2.55 USD Chroma Case Key Counter-Strike: Global Offensive 393 Starting at: $4.86 USD StatTrak™ AK-47 | Elite Build (Field-Tested) Counter-Strike: Global Offensive 269 Starting at: $3.50 USD AK-47 | Cartel (Field-Tested) Counter-Strike: Global Offensive 521 Starting at: $2.83 USD AWP | Phobos (Factory New) Counter-Strike: Global Offensive 54 Starting at: $27.53 USD AK-47 | Aquamarine Revenge (Minimal Wear) Counter-Strike: Global Offensive 427 Starting at: $1.23 USD USP-S | Guardian (Minimal Wear) Counter-Strike: Global Offensive 158 Starting at: $26.04 USD AWP | BOOM (Minimal Wear) Counter-Strike: Global Offensive 432 Starting at: $1.66 USD M4A1-S | Flashback (Minimal Wear) Counter-Strike: Global Offensive 459 Starting at: $1.24 USD USP-S | Torque (Factory New) Counter-Strike: Global Offensive 341 Starting at: $1.00 USD USP-S | Torque (Minimal Wear) Counter-Strike: Global Offensive 305 Starting at: $5.03 USD Desert Eagle | Kumicho Dragon (Field-Tested) Counter-Strike: Global Offensive 268 Starting at: $8.30 USD M4A1-S | Cyrex (Minimal Wear) Counter-Strike: Global Offensive 218 Starting at: $4.39 USD M4A4 | Evil Daimyo (Factory New) Counter-Strike: Global Offensive 570 Starting at: $4.02 USD AK-47 | Blue Laminate (Minimal Wear) Counter-Strike: Global Offensive 1,060 Starting at: $0.71 USD Desert Eagle | Oxide Blaze (Factory New) Counter-Strike: Global Offensive 128 Starting at: $9.13 USD M4A4 | 龍王 (Dragon King) (Minimal Wear) Counter-Strike: Global Offensive 140 Starting at: $9.90 USD AK-47 | Orbit Mk01 (Factory New) Counter-Strike: Global Offensive'; 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