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

/
/
gms

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/^(.{14}).*\s^(?=.{0,14}^\1.*)/ms'; $str = '09/07/21,10:00,11.a,100,11.6,5,13,330,6.0,2.8,1014.0,33.0,23.8,44,5,11.6,11.6,0.0,75,0.00,579.70,11.0,444,0.0,320,0.0,31.7,11.4,13.6 09/07/21,10:00,11.c,100,11.6,6,13,330,6.0,2.8,1014.0,33.0,23.8,44,5,11.6,11.6,0.0,75,0.00,579.70,11.0,444,0.0,320,0.0,31.7,11.4,13.6 09/07/21,10:00,11.b,100,11.6,6,13,330,6.0,2.8,1014.0,33.0,23.8,44,5,11.6,11.6,0.0,75,0.00,579.70,11.0,444,0.0,320,0.0,31.7,11.4,13.6 09/07/21,10:10,11.7,100,11.7,6,15,337,1.2,3.3,1013.9,33.5,23.9,44,4,11.7,11.7,0.0,82,0.00,579.70,11.1,465,0.0,330,0.0,32.2,11.4,13.8 09/07/21,10:10,11.7,100,11.7,6,15,337,1.2,3.3,1013.9,33.5,23.9,44,4,11.7,11.7,0.0,82,0.00,579.70,11.0,465,0.0,330,0.0,32.2,11.4,13.8 09/07/21,10:20,11.9,100,11.9,6,11,337,3.0,3.8,1013.9,34.0,24.0,44,6,11.9,11.9,1.0,198,0.00,579.70,11.2,484,0.0,354,0.0,32.7,11.5,14.1 09/07/21,10:20,11.9,100,11.9,6,11,336,3.0,3.8,1013.9,34.0,24.0,44,6,11.9,11.9,1.0,198,0.00,579.70,11.3,484,0.0,354,0.0,32.7,11.6,14.1 09/07/21,10:30,12.1,100,12.1,5,13,345,1.8,4.1,1013.7,34.3,24.0,45,9,12.1,12.1,1.0,177,0.00,579.70,11.7,502,0.0,355,0.0,33.0,12.0,14.4 09/07/21,10:30,12.1,100,12.1,6,13,344,1.8,4.1,1013.7,34.3,24.0,45,9,12.1,12.1,1.0,182,0.00,579.70,11.7,502,0.0,337,0.0,33.0,11.9,14.4 07/07/21,16:50,14.4,40,1.0,2,2,237,0.0,0.0,953.8,0.0,26.0,32,1,14.4,14.4,0.0,14,0.00,579.70,12.3,4,0.1,237,0.0,0.0,13.9,12.5 07/07/21,16:50,14.4,40,1.0,2,2,237,0.0,0.0,953.8,0.0,26.0,32,1,14.4,14.4,0.0,14,0.00,579.70,12.3,4,0.1,237,0.0,0.0,13.9,12.5 07/07/21,17:00,13.4,43,1.1,0,1,237,0.0,0.0,953.7,0.0,25.7,33,0,13.4,13.4,0.0,7,0.00,579.70,11.5,0,0.3,237,0.0,0.0,13.1,11.5 07/07/21,17:00,13.4,43,1.1,0,1,237,0.0,0.0,953.7,0.0,25.7,33,0,13.4,13.4,0.0,7,0.00,579.70,11.5,0,0.3,237,0.0,0.0,13.1,11.5 07/07/21,17:10,12.7,46,1.4,0,0,0,0.0,0.0,953.9,0.0,25.3,32,0,12.7,12.7,0.0,2,0.00,579.70,10.9,0,0.4,237,0.0,0.0,12.5,10.9 07/07/21,17:20,11.3,51,1.5,0,0,0,0.0,0.0,953.8,0.0,25.1,33,0,11.3,11.3,0.0,0,0.00,579.70,9.5,0,0.5,237,0.0,0.0,11.2,9.5 07/07/21,17:20,11.3,51,1.5,0,0,0,0.0,0.0,953.8,0.0,25.1,33,0,11.3,11.3,0.0,0,0.00,579.70,9.5,0,0.5,237,0.0,0.0,11.2,9.5 07/07/21,17:30,10.3,55,1.6,0,0,0,0.0,0.0,954.0,0.0,24.8,33,0,10.3,10.3,0.0,0,0.00,579.70,8.6,0,0.5,237,0.0,0.0,10.3,8.6 07/07/21,17:30,10.3,55,1.6,0,0,0,0.0,0.0,954.0,0.0,24.8,33,0,10.3,10.3,0.0,0,0.00,579.70,8.6,0,0.5,237,0.0,0.0,10.3,8.6 '; $subst = ""; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;

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