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
  • 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 = '@/(?:images)(?:/[0-9A-Za-z_]+){6,14}\.(?:avi|bmp|gif)$@mi'; $str = '# True Positives: /images/SSzSTaOcH1pR_2F/IWb3AQ88iG_2Fz3s_2/FYkkdHOcR/pRMVw2WWbSuH7xwk6D_2/B3mPLWnQSf9j_2FbJ9d/mGZcHG2v_2FOV9FT3uU1j4/Diayqm3GEgLZw/n5GTPplw/QLepJPJJ9aQEAyFymOCZWZT/aGYTa7jBoo/9rw_2BTif5Y_2BfXr/M4lxihZ_2FtN5p/t.avi /images/Uc2TJpGPts/FfQPYEIa9cTp5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qOIi0Qqmbsku/iC2ceSPq/qditqiLXeKOytyo58Iga/KtJBIuhqsLzYH01Zz7LP/Oma_2BqMvNi39Jf/cBCvfx.bmp # False Positives: /templates/system/images/Jiduasdqwqnwd.rar /images/1 /images/2 /images/3 '; 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