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

r"
"
gm

Test String

Code Generator

Generated Code

$re = '/\'name\': ([\'\"])(.*?)\1, \'awardedAt\': (-?\d+),/m'; $str = '[{\'name\': \'Locus Award\', \'awardedAt\': 1230796800000, \'category\': \'Best Young Adult Book\', \'hasWon\': None}, {\'name\': \'Georgia Peach Book Award\', \'awardedAt\': 1230796800000, \'category\': \'\', \'hasWon\': None}, {\'name\': \'Buxtehuder Bulle\', \'awardedAt\': 1230796800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Golden Duck Award\', \'awardedAt\': 1230796800000, \'category\': \'Young Adult (Hal Clement Award)\', \'hasWon\': None}, {\'name\': "Grand Prix de l\'Imaginaire", \'awardedAt\': 1262332800000, \'category\': \'Roman jeunesse étranger\', \'hasWon\': None}, {\'name\': \'Books I Loved Best Yearly (BILBY) Awards\', \'awardedAt\': 1325404800000, \'category\': \'Older Readers\', \'hasWon\': None}, {\'name\': "West Australian Young Readers\' Book Award (WAYRBA)", \'awardedAt\': 1262332800000, \'category\': \'Older Readers\', \'hasWon\': None}, {\'name\': "Red House Children\'s Book Award", \'awardedAt\': 1262332800000, \'category\': \'Older Readers & Overall\', \'hasWon\': None}, {\'name\': \'South Carolina Book Award\', \'awardedAt\': 1293868800000, \'category\': \'Junior and Young Adult Book\', \'hasWon\': None}, {\'name\': \'Charlotte Award\', \'awardedAt\': 1262332800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Colorado Blue Spruce Young Adult Book Award\', \'awardedAt\': 1262332800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Teen Buckeye Book Award\', \'awardedAt\': 1230796800000, \'category\': None, \'hasWon\': None}, {\'name\': "Pennsylvania Young Readers\' Choice Award", \'awardedAt\': 1262332800000, \'category\': \'Young Adults\', \'hasWon\': None}, {\'name\': \'Rhode Island Teen Book Award\', \'awardedAt\': 1262332800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Vermont Golden Dome Book Award\', \'awardedAt\': 1262332800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Evergreen Teen Book Award\', \'awardedAt\': 1293868800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Soaring Eagle Book Award\', \'awardedAt\': 1230796800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Milwaukee County Teen Book Award\', \'awardedAt\': 1262332800000, \'category\': \'\', \'hasWon\': None}, {\'name\': \'Sakura Medal\', \'awardedAt\': 1262332800000, \'category\': \'Middle School Book\', \'hasWon\': None}, {\'name\': \'Michigan Library Association Thumbs Up! Award\', \'awardedAt\': 1230796800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Florida Teens Read\', \'awardedAt\': 1230796800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Deutscher Jugendliteraturpreis\', \'awardedAt\': 1262332800000, \'category\': \'Preis der Jugendjury\', \'hasWon\': None}, {\'name\': \'Iowa High School Book Award\', \'awardedAt\': 1293868800000, \'category\': \'\', \'hasWon\': None}, {\'name\': \'New Mexico Land of Enchantment Award\', \'awardedAt\': 1293868800000, \'category\': \'Young Adult\', \'hasWon\': None}, {\'name\': \'Eliot Rosewater Indiana High School Book Award\', \'awardedAt\': 1262332800000, \'category\': None, \'hasWon\': None}, {\'name\': \'The Inky Awards\', \'awardedAt\': 1230796800000, \'category\': \'Silver Inky\', \'hasWon\': None}, {\'name\': \'California Young Readers Medal\', \'awardedAt\': 1293868800000, \'category\': \'Young Adult\', \'hasWon\': None}, {\'name\': \'Lincoln Award\', \'awardedAt\': 1293868800000, \'category\': \'\', \'hasWon\': None}, {\'name\': \'Kinderboekwinkelprijs\', \'awardedAt\': 1262332800000, \'category\': \'\', \'hasWon\': None}, {\'name\': \'Truman Readers Award\', \'awardedAt\': 1293868800000, \'category\': None, \'hasWon\': None}, {\'name\': \'CYBILS Award\', \'awardedAt\': 1199174400000, \'category\': \'Young Adult Fantasy & Science Fiction\', \'hasWon\': None}, {\'name\': \'Literaturpreis der Jury der jungen Leser\', \'awardedAt\': 1262332800000, \'category\': \'Jugendbuch\', \'hasWon\': None}, {\'name\': \'The Inky Awards Shortlist\', \'awardedAt\': 1230796800000, \'category\': \'Silver Inky\', \'hasWon\': None}, {\'name\': \'Prix Et-lisez-moi\', \'awardedAt\': 1293868800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Gateway Readers Award\', \'awardedAt\': 1293868800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Oklahoma Sequoyah Award\', \'awardedAt\': 1293868800000, \'category\': \'High School and Intermediate\', \'hasWon\': None}, {\'name\': \'Premio El Templo de las Mil Puertas\', \'awardedAt\': 1230796800000, \'category\': \'Mejor novela extranjera perteneciente a saga\', \'hasWon\': None}, {\'name\': "Rebecca Caudill Young Readers\' Book Award", \'awardedAt\': 1293868800000, \'category\': None, \'hasWon\': None}, {\'name\': \'LovelyBooks Leserpreis\', \'awardedAt\': 1230796800000, \'category\': \'Fantasy\', \'hasWon\': None}, {\'name\': \'LovelyBooks Leserpreis for Bestes Cover/Umschlag\', \'awardedAt\': 1230796800000, \'category\': None, \'hasWon\': None}, {\'name\': \'Premi Protagonista Jove\', \'awardedAt\': 1230796800000, \'category\': \'Categoria 12-14 anys\', \'hasWon\': None}] '; 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