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 = '/(Â|â|Ã|\||©|®|™)/m'; $str = 'Calcaneal Locking Plate â Aspen Richard-Allan® Surgical Needle, Keith’s Abdominal Cutting, Straight 0.03 in x 2.244 in Laborie T-DOC® Single Sensor Coudé Catheter, Coude Tip 7 Fr Hydrocellular Foam Dressings SILICONE ADHESIVE | WITH BORDER | Sacral | GENTLE ADHESIVE | STERILE 7" x 7" Dressing 5" x 5" Pad 00612479126886 c1c1a9c5-39a6-4816-8577-256b35dd2908 New Published 1 2018-11-05 2018-10-05 NULL In Commercial Distribution McKesson 16-4063 NULL 023904428 MCKESSON MEDICAL-SURGICAL INC. 96 Gauze Bandage Roll NON-STERILE 6-PLY | 100% COTTON 3.4" x 3.6 Yards false true false false false true true false false false false false true Labeling does not contain MRI Safety Information false false false false FULLDownload_Part95_Of_100_2020-04-01.xml 2020-04-01 Full GUDID load 2020-04-01T04:19:25 2020-04-03 12:46:39.6105233 9999-12-31 23:59:59.9999999'; 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