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

/
/
g

Test String

Code Generator

Generated Code

$re = '/([^&=]+)=([^&]*)/'; $str = 'id_token=eyJhbGciOiJSUzI1NiIsImtpZCI6IjZCN0FDQzUyMDMwNUJGREI0RjcyNTJEQUVCMjE3N0NDMDkxRkFBRTEiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJhM3JNVWdNRnY5dFBjbExhNnlGM3pBa2ZxdUUifQ.eyJuYmYiOjE0NzE5NzQ0MzEsImV4cCI6MTQ3MTk3NDczMSwiaXNzIjoiaHR0cDovLzE2OS4yNTQuODAuODA6NDUwMCIsImF1ZCI6ImlvbmljQ2xpZW50Iiwibm9uY2U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0.LNVEWtOmUHGXgIamHzJJQ2-x7RiREOb9JTFEAPKMiyzGwpn7VIwtnCgmmXZlgkN-7gSDj5T7OmhyCQVvnTfK57UvLotzT-egLLjQI3WAdOQanXxo5hKpAPO1H0neLsHmW9Oa4DFK3Ft9-F7aovsA2gxwZ6axnP1_NCn9vg4jWmhU3gwfq_DsjUqhUgr73qvPa_mfENIPcS0p5v6pG9xu6PE1ECHw7Zg__9JeX0oQ7Eg3rzH6X8SwUBhOU0-51svCziFMj42hi3fZfbiEtzzvJq999___YA4PdJ0F-esnWo8LFWmceJViOQgLwzL7sfxv07sgsL3kBouxu9R0_zcvBA&token_type=Bearer&expires_in=3600&scope=openid%20email%20api1&state=3482997620966838&session_state=cy5gU2jp6Y3ip-si4Erap3XrL6DvMZtHTBmvzeuEi5Q.8cd75f271a72fb7b0920bddd2df2f171"'; 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