Regular Expressions 101

Save & Manage Regex

  • Current Version: 2
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
  • 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
Processing...

Test String

Code Generator

Generated Code

$re = '/(?is)Listing archive:([^L]|L(?!isting archive:))*?(Path = |\\\\)\Q16.exe\E.*?\QSize = 9664\E/m'; $str = 'Listing archive: C:\\Games\\15x15 (1996).zip -- Path = C:\\Games\\15x15 (1996).zip Type = zip Physical Size = 645312 Comment = TORRENTZIPPED-8941A490 ---------- Path = 15x15 Folder = + Size = 0 Packed Size = 2 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = D Encrypted = - Comment = CRC = Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 0 Path = 15x15\\config.com Folder = - Size = 247 Packed Size = 246 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = 40AC556A Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 38 Path = 15x15\\CONFIG.DAT Folder = - Size = 20 Packed Size = 9 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = 855F9E6A Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 330 Path = 15x15\\nikita.cfg Folder = - Size = 14 Packed Size = 9 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = A1E0E1D6 Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 385 Path = 15x15\\puz.dat Folder = - Size = 100 Packed Size = 6 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = 9988C6CA Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 440 Path = 15x15\\puz1.dat Folder = - Size = 175724 Packed Size = 165634 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = 3AB2387B Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 489 Path = 15x15\\puz2.dat Folder = - Size = 179346 Packed Size = 169946 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = BCC000B6 Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 166167 Path = 15x15\\puz3.dat Folder = - Size = 151778 Packed Size = 139785 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = A8287EAB Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 336157 Path = 15x15\\puzlib Folder = - Size = 153120 Packed Size = 137634 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = BBDDB987 Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 475986 Path = 15x15\\puzzle.exe Folder = - Size = 76248 Packed Size = 30846 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = 684E0862 Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 613662 Path = 15x15\\puzzle.res Folder = - Size = 640 Packed Size = 9 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = 4B7716DA Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 644554 Listing archive: C:\\Games\\16 (1996).zip -- Path = C:\\Games\\16 (1996).zip Type = zip Physical Size = 7418 Comment = TORRENTZIPPED-A84874F9 ---------- Path = 16STR Folder = + Size = 0 Packed Size = 2 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = D Encrypted = - Comment = CRC = Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 0 Path = 16STR\\16 (1996).ba1 Folder = - Size = 80 Packed Size = 59 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = FADCCFD2 Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 38 Path = 16STR\\16.EXE Folder = - Size = 9664 Packed Size = 5406 Modified = 1996-12-24 23:32:00 Created = Accessed = Attributes = Encrypted = - Comment = CRC = 7096C0BE Method = Deflate:Maximum Characteristics = Host OS = FAT Version = 20 Volume Index = 0 Offset = 147'; 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