Regular Expressions 101

Save & Share

  • Save new Regex
    ctrl+s
  • Update 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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

/
/
gmi

Test String

Code Generator

Generated Code

$re = '/^(?>.*?(\pL)(?!.*\1)){26}/mi'; $str = '# Pangrams Cwm fjord bank glyphs vext quiz. Fox nymphs grab quick jived waltz. Glib jocks quiz nymph to vex dwarf. Quick zephyrs blow, vexing daft Jim. How vexingly quick daft zebras jump! Mr. Jock, TV quiz PhD, bags few lynx. Sphinx of black quartz, judge my vow. The five boxing wizards jump quickly. Waltz, nymph, for quick jigs vex Bud. Quick fox jumps nightly above wizard. Jackdaws love my big sphinx of quartz. Two driven jocks help fax my big quiz. Fickle jinx bog dwarves spy math quiz. Public junk dwarves hug my quartz fox. Five quacking zephyrs jolt my wax bed. Pack my box with five dozen liquor jugs. Sympathizing would fix Quaker objectives. When zombies arrive, quickly fax judge Pat. Waxy and quivering, jocks fumble the pizza. The quick brown fox jumps over the lazy dog. Woven silk pyjamas exchanged for blue quartz. The jay, pig, fox, zebra and my wolves quack! A wizard\'s job is to vex chumps quickly in fog. The quick onyx goblin jumps over the lazy dwarf. Foxy diva Jennifer Lopez wasn\'t baking my quiche. Watch "Jeopardy!", Alex Trebek\'s fun TV quiz game. By Jove, my quick study of lexicography won a prize! My girl wove six dozen plaid jackets before she quit. Grumpy wizards make a toxic brew for the jovial queen. A quivering Texas zombie fought republic linked jewelry. The wizard quickly jinxed the gnomes before they vaporized. All questions asked by five watched experts amaze the judge. Back in June we delivered oxygen equipment of the same size. We promptly judged antique ivory buckles for the next prize. Jim quickly realized that the beautiful gowns are expensive. # Near-pangrams (25 letters) Cwm bank glyphs quiz vext Ford. Fox nymphs grab quick jive waltz. Glib jock dwarves vet ox nymph quiz. Quick zephyrs blow, vexing daft Jon. How vexingly quick daft zebras pump! Ms. Jock, TV quiz PhD, bags few lynx. Sphinges of black quartz, judge my vow. The four boxing wizards jump quickly. Waltz, nymph, or quick jigs vex Bud. Quick fox jumps nightly over wizard. Jackdaws love my big quartz sphinx. Driven jocks help fax my big owl quiz. Fickle jinx bog dwarves ham spy quiz. Public junk dwarves hug my quartz ox. Aw, five quacking zephyrs jolt my bed. Pack my ox with five dozen liquor jugs. Sympathizing would nix Quaker objectives. When zombies arrive at fax, quickly judge. Waxy jocks quivered and fumbled the pizza. The quick brown fox jumps over the zany dog. Exchange woven silk pyjamas for blue quartz. The jays, pig, fox, zebra and my wolf quack! A wizard\'s job is to quickly finger ex-chumps. The quirky lazy dwarf jumps over the onyx bling. Foxy diva Jennifer Lopez was baking my quiche. Watch "Jeopardy!", Alex Trebek\'s fun quiz game. By Jove, my study of quine lexicography won a prize! Your girl wove six dozen plaid jackets before she quit. Grumpy wizards create a toxic brew for the jovial queen. A quivering Texas zombie fought ink republic jewelry. The wizard quickly jinxed the gnome before he vaporized. The judge asked all questions amassed by five watched experts. Back in May we delivered oxygen equipment of the same size. She promptly judged antique ivory buckles for the next prize. Jon quickly realized that the beautiful gowns are expensive. # Near-pangrams (23-24 letters, from MASC wordsense) Squash has become a popular racket game and facilities are widely available. Equally coveted is the sexy Y2K logo (named for the millennial computer bug). Dole is sorely tempted to forget everything he knows about the 1980s tax cuts. The officers have been placed on administrative duty while a grand jury examines the case. Head up the hill above the town to explore the remains of the ancient Greek town of Sybrita. "I can at least partly save the movie from being wrecked by Herzog\'s bungling," writes Kinski. To answer this question, Vygotsky proposed a special concept: the zone of proximal development.'; 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