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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/^vm:\S{8}-\S{4}-\S{4}-\S{4}-\S{12}:.*$/m'; $str = 'vm:5023b75c-aa10-6ef8-c639-e1efe80fca7a:vcsa_s4_outils vm:523a0ca1-89d3-4046-6d6d-5445969926b5:vcsa_s4_outils vm:523dd865-45aa-d880-4621-0d6fc3809abe:vcsa_s4_outils vm:5001699f-d1bd-e592-a437-215fb3778655:vcsa_s4_outils vm:5001f139-0316-db40-41ed-b740c0f87f58:vcsa_s4_outils vm:5001d2b4-d3bc-7b77-4b4d-950bca31f221:vcsa_s4_outils vm:50010b5e-0bfb-b87f-3c1a-75a0dbaa0ac9:vcsa_s4_outils vm:5023e4e3-02b2-c9b4-17bb-43ad16c6f7c4:vcsa_s4_outils vm:5023e4e3-02b2-c9b4-17bb-43ad16c6f7c4:vcsa_s4_outils vm:500166d2-d055-9aa5-a713-33d47fa53e2b:vcsa_s4_outils vm:502376fe-b601-6346-806a-c487048fee38:vcsa_s4_outils vm:50018b5b-cd97-22d4-2ab6-7bf0c78c9dc6:vcsa_s4_outils vm:5001cbab-122d-0278-eec2-710019b2a428:vcsa_s4_outils vm:50236d7c-8675-792e-1875-641e04a7cbd6:vcsa_s4_outils vm:5001ed33-865b-d7c9-1201-f38a9a386dbb:vcsa_s4_outils vm:5001a47d-5e94-11e6-3fa9-5bf4908427c9:vcsa_s4_outils vm:5023bbc5-a48e-9262-173e-248ccd987d04:vcsa_s4_outils vm:503fe992-c690-7528-75b5-8a2c1e47c3d1:oto-vcenter-02-pr.dc.infra-grdf.com vm:50046e04-7d48-6748-8b9e-f1cdad98be16:sv-svb-pr-vcenter-3.dc.infra-grdf.com vm:50046e04-7d48-6748-8b9e-f1cdad98be16:sv-svb-pr-vcenter-4.dc.infra-grdf.com vm:50324e4a-082f-7e4e-626e-69c87e65b068:oto-vcenter-02-pr.dc.infra-grdf.com vm:501d8240-7a4c-5f62-e054-235bd06bf674:sv-svb-pr-vcenter-4.dc.infra-grdf.com vm:503b98a3-e244-9508-59fe-cc2925b2201d:sv-svb-pr-vcenter-3.dc.infra-grdf.com vm:5001ec2f-af14-2888-2fc6-005d6802c304:vcsa_s4_outils vm:50017436-aa25-a2f0-b516-96eeb6e863ea:vcsa_s4_outils vm:5001a1b0-ad7b-9e8e-f9e2-2fc9bab961d3:vcsa_s4_outils vm:50235f15-8eb2-f721-e7a7-07d73d7989ba:vcsa_s4_outils vm:5001e19e-e1f3-b178-1cbf-4531e34b6a6b:vcsa_s4_outils vm:50016332-4832-e391-7acc-8aa94d3dae2a:vcsa_s4_outils vm:50231010-ac32-c6d5-ce6e-dde3d167b018:vcsa_s4_outils vm:50012a50-654d-7e61-669e-549a83538e52:vcsa_s4_outils vm:5001992a-4f1f-145c-9547-ef0eccda5db2:vcsa_s4_outils vm:5001e878-2a7d-6077-f2e4-288155e99373:vcsa_s4_outils vm:50014bf0-b0ea-517a-67b5-fdc4e0b95f6b:vcsa_s4_outils vm:50016583-26b6-1012-b1b1-db490f93f811:vcsa_s4_outils vm:50236622-9b0e-1159-4522-90791e546b2d:vcsa_s4_outils vm:5023e5c3-0816-9e21-3120-284dc5c3d093:vcsa_s4_outils vm:502398fe-5ee4-47e2-8629-39fd5dba0dad:vcsa_s4_outils vm:5267d7a7-5378-d247-1ed3-067a430ad6f9:vcsa_s4_outils vm:50010f12-33db-4777-b507-9c4dfe2a1924:vcsa_s4_outils '; 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