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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/^(?!15).*/m'; $str = '13 13.1 13.1.1 13.1.2 13.1.2 13.1.3 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.4 13.4 13.4.1 13.4.1 13.5 13.5.1 13.6 13.6.1 13.7 14 14.0.1 14.1 14.2 14.2 14.2.1 14.3 14.4 14.4.1 14.4.2 14.5 14.5.1 14.6 Beta 3 14.6 RC 14.6 RC 2 14.6 14.7 Beta 1 14.7 Beta 2 14.7 Beta 3 14.7 Beta 4 14.7 Beta 5 14.7 RC 14.7 14.7.1 14.8 14.8.1 15.0 Beta 1 15.0 Beta 2 15.0 Beta 2 15.0 Beta 3 15.0 Beta 4 15.0 Beta 5 15.0 Beta 6 15.0 Beta 7 15.0 Beta 8 15.0 RC 15 15.1 Beta 1 15.1 Beta 2 15.0.1 15.1 Beta 3 15.0.2 15.1 Beta 4 15.1 RC 1 15.1 RC 2 15.1 15.2 Beta 1 15.2 Beta 2 15.2 Beta 3 15.1.1 15.2 Beta 4 15.2 RC 15.2 RC 2 15.2 15.3 Beta 1 15.2.1 15.3 Beta 2 15.3 RC 15.3 15.4 Beta 1 15.4 Beta 2 15.3.1 15.4 Beta 3 15.4 Beta 4 15.4 Beta 5 15.4 RC 15.4 15.4.1 15.5 Beta 1 15.5 Beta 2 15.5 Beta 3 15.5 Beta 4 15.5 RC 15.5 15.6 Beta 1 15.6 Beta 2 15.6 Beta 3 15.6 Beta 4 15.6 Beta 5 15.6 RC 15.6 RC 2 15.6 15.6.1 15.7 RC 15.7 15.7.1 RC 15.7.1 15.7.2 RC 16.0 Beta 1 16.0 Beta 2 16.0 Beta 3 16.0 Beta 3 16.0 Public Beta 1 16.0 Beta 4 16.0 Public Beta 2 16.0 Beta 5 16.0 Public Beta 3 16.0 Beta 6 16.0 Public Beta 4 16.0 Beta 7 16.0 Public Beta 5 16.0 Beta 8 16.0 Public Beta 6 16.0 RC 16 16.1 Beta 1 16.0.1 16.1 Public Beta 1 16.1 Beta 2 16.1 Public Beta 2 16.0.2 16.1 Beta 3 16.1 Public Beta 3 16.1 Beta 4 16.1 Public Beta 4 16.0.3 16.1 Beta 5 16.1 Public Beta 5 16.1 RC 16.1 16.2 Beta 1 16.2 Public Beta 1 16.2 Beta 2 16.1.1 16.2 Public Beta 2 16.2 Beta 3 16.2 Public Beta 3 16.2 (a) 16.2 (b) 16.1.2 16.2 Beta 4 16.2 RC'; 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