Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new 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
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

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r"(?m)(?:(dataLayerLocal\.products = ))\[.*\];").unwrap(); let string = "<script type=\"text/javascript\"> dataLayerLocal.products = dataLayerLocal.products || []; dataLayerLocal.products = [{'amount':'0','categories':['Gereizte Augen','Augentropfen','Augentropfen','Augentropfen'],'categoryIds':['A001G001','A003E001A001','A003G002A001','A003T001A001'],'name':'Artelac Complete EDO','price':1399,'pzn':'11617896'},{'amount':'0','categories':['Fenistil'],'categoryIds':['A001F001'],'name':'Fenistil Dragees','price':599,'pzn':'00376975'},{'amount':'0','categories':['Gereizte Haut','Gesichtspflege f\\xFCr allergische Haut','Insektenstiche','Sonnenallergie & Mallorca-Akne','Basispflege & Reinigung'],'categoryIds':['A001G002','HN001A002G001','HN001A002I002','HN001A002S001','HN001N001B001'],'name':'Linola akut 0,5% Creme','price':969,'pzn':'02138990'},{'amount':'0','categories':['Gereizte Nase','Bei Allergie'],'categoryIds':['A001G003','EN002S001N003B002'],'name':'Otri-Allergie Nasenspray Fluticason','price':1049,'pzn':'12400130'},{'amount':'0','categories':['Gereizte Haut','Insektenstiche','Sonnen- & Insektenschutz'],'categoryIds':['A001G002','HN001A002I002','M004K001S003'],'name':'Soventol Gel, 20 mg Bamipin','price':499,'pzn':'00949632'},{'amount':'0','categories':['Gereizte Haut','Nachtpflege','Tagespflege','Tagespflege','empfindliche Haut','trockene Haut'],'categoryIds':['A001G002','KN001A002N001','KN001A002T001','KN001R001T001','KN001G001T001E001','KN001G001T001T001'],'name':'Eucerin UltraSensitive Beruhigende Pflege trockene Haut','price':1729,'pzn':'10268672'},{'amount':'0','categories':['Gereizte Haut','empfindliche Haut'],'categoryIds':['A001G002','KN001K001R001E001'],'name':'Eucerin pH5 Hautschutz Duschgel','price':799,'pzn':'13889245'},{'amount':'0','categories':['Gereizte Haut','empfindliche Haut'],'categoryIds':['A001G002','KN001K001R001E001'],'name':'Eucerin pH5 Hautschutz Dusch\\xF6l','price':1469,'pzn':'13889038'},{'amount':'0','categories':['Zum Einnehmen'],'categoryIds':['A001Z001'],'name':'Allvent Kapseln','price':2095,'pzn':'05884185'},{'amount':'0','categories':['Gereizte Haut','Nachtpflege','Tagespflege','Tagespflege','normale bis Mischhaut'],'categoryIds':['A001G002','KN001A002N001','KN001A002T001','KN001R001T001','KN001G001T001N001'],'name':'Eucerin UltraSensitive Beruhigende Pflege Normale/Mischhaut','price':1729,'pzn':'10268689'},{'amount':'0','categories':['Gereizte Nase','Bei Allergie'],'categoryIds':['A001G003','EN002S001N003B002'],'name':'Pollival 1 mg/ml','price':899,'pzn':'13748585'},{'amount':'0','categories':['Gereizte Haut'],'categoryIds':['A001G002'],'name':'Eucerin pH5 Hautschutz Lotion','price':1859,'pzn':'13889156'},{'amount':'0','categories':['Gereizte Haut','Reinigung','Gesichtsreinigung','empfindliche Haut','Gesichtsreinigung'],'categoryIds':['A001G002','HN001R001R001','KN001A002G001','KN001G002E001','KN001R001G001'],'name':'Eucerin UltraSensitive Reinigungslotion','price':1199,'pzn':'10268695'},{'amount':'0','categories':['Gereizte Haut','Gesichtspflege f\\xFCr allergische Haut','Insektenstiche','K\\xF6rperpflege & Reinigung','Sonnenallergie & Mallorca-Akne','Basispflege & Reinigung','Notfallapotheke'],'categoryIds':['A001G002','HN001A002G001','HN001A002I002','HN001A002K001','HN001A002S001','HN001N001B001','M004K001N002'],'name':'Ebenol 0,25% Creme','price':1089,'pzn':'04479152'},{'amount':'0','categories':['Cetirizin'],'categoryIds':['A001C001'],'name':'Cetirizin AL Direkt Lutschtabletten','price':699,'pzn':'00927352'},{'amount':'0','categories':['Gereizte Haut'],'categoryIds':['A001G002'],'name':'Eucerin pH5 Hautschutz Creme F','price':1648,'pzn':'13889096'},{'amount':'0','categories':['Gereizte Haut'],'categoryIds':['A001G002'],'name':'Eucerin pH5 Hautschutz Lotion F','price':1798,'pzn':'13889185'},{'amount':'0','categories':['Gereizte Haut','Gesichtspflege f\\xFCr allergische Haut','Insektenstiche','Sonnenallergie & Mallorca-Akne','Basispflege & Reinigung','Hauterkrankungen','Haut- & K\\xF6rperpflege','Komplexmittel','Haut, Haare & N\\xE4gel','Magen & Darm'],'categoryIds':['A001G002','HN001A002G001','HN001A002I002','HN001A002S001','HN001N001B001','M004B001H001','M004K001H003','N001H001K001','N001P001H001','N001P001M001'],'name':'Dermaplant Salbe','price':669,'pzn':'01713512'},{'amount':'0','categories':['Gereizte Nase','Immunsystem unterst\\xFCtzen','Schnupfen & Ohrenschmerzen','Befeuchtend & pflegend','Bei Allergie'],'categoryIds':['A001G003','EN002V001I001','M004K001S002','EN002S001N003B001','EN002S001N003B002'],'name':'RCPflege N Nasen und Rachenspray','price':429,'pzn':'06415162'},{'amount':'0','categories':['Allergie & Heuschnupfen','Allergie & Heuschnupfen'],'categoryIds':['A001','N001P001A001'],'name':'Pascallerg','price':1079,'pzn':'07703644'},{'amount':'0','categories':['Gereizte Haut'],'categoryIds':['A001G002'],'name':'Eucerin pH5 Hautschutz Lotion F','price':1898,'pzn':'13889179'},{'amount':'0','categories':['Gereizte Haut','empfindliche Haut'],'categoryIds':['A001G002','KN001K001R001E001'],'name':'Eucerin pH5 Hautschutz Dusch\\xF6l','price':1499,'pzn':'13889021'},{'amount':'0','categories':['Gereizte Haut','empfindliche Haut'],'categoryIds':['A001G002','KN001K001R001E001'],'name':'Eucerin pH5 Hautschutz Waschlotion','price':1099,'pzn':'13889222'},{'amount':'0','categories':['Gereizte Augen','Gereizte Nase','Zum Einnehmen','Allergisch empfindliche Augen','Komplexmittel','Allergie & Heuschnupfen'],'categoryIds':['A001G001','A001G003','A001Z001','A003G002A002','N001H001K001','N001P001A001'],'name':'Klosterfrau Allergin fl\\xFCssig','price':969,'pzn':'02855556'},{'amount':'0','categories':['Gereizte Augen','Gereizte Nase','Zum Einnehmen','Allergisch empfindliche Augen'],'categoryIds':['A001G001','A001G003','A001Z001','A003G002A002'],'name':'Loratadin AL 10 mg Tabletten','price':1822,'pzn':'01653945'},{'amount':'0','categories':['Gereizte Nase','Zum Einnehmen','Komplexmittel','Allergie & Heuschnupfen'],'categoryIds':['A001G003','A001Z001','N001H001K001','N001P001A001'],'name':'Heuschnupfenmittel DHU Mischung','price':892,'pzn':'01905022'},{'amount':'0','categories':['Loratadin','Zum Einnehmen','Allergie & Heuschnupfen'],'categoryIds':['A001L001','A001Z001','N001P001A001'],'name':'Loratadin ratiopharm 10 mg','price':1199,'pzn':'00142906'},{'amount':'0','categories':['Loratadin'],'categoryIds':['A001L001'],'name':'Lorano Pro','price':1975,'pzn':'10090197'},{'amount':'0','categories':['Gereizte Haut'],'categoryIds':['A001G002'],'name':'Eucerin pH5 Hautschutz Creme','price':1569,'pzn':'13889073'},{'amount':'0','categories':['Gereizte Augen','Zum Einnehmen','Allergisch empfindliche Augen','Komplexmittel','Allergie & Heuschnupfen'],'categoryIds':['A001G001','A001Z001','A003G002A002','N001H001K001','N001P001A001'],'name':'Klosterfrau Allergin Tabletten','price':878,'pzn':'05961218'},{'amount':'0','categories':['Gereizte Augen','Zum Einnehmen','Pflanzlich & Hom\\xF6opathisch','Schnupfen & Nasennebenh\\xF6hlenentz\\xFCndung','Allergisch empfindliche Augen','Allergie & Heuschnupfen'],'categoryIds':['A001G001','A001Z001','EN002P001','EN002S001','A003G002A002','N001P001A001'],'name':'Luffanest Tabletten','price':1317,'pzn':'01828511'},{'amount':'0','categories':['Gereizte Augen','Gereizte Nase','Zum Einnehmen','Allergisch empfindliche Augen','Komplexmittel','Allergie & Heuschnupfen'],'categoryIds':['A001G001','A001G003','A001Z001','A003G002A002','N001H001K001','N001P001A001'],'name':'allergoLoges','price':1549,'pzn':'00910512'},{'amount':'0','categories':['Gereizte Haut'],'categoryIds':['A001G002'],'name':'Eucerin pH5 Hautschutz Lotion','price':1969,'pzn':'13889133'},{'amount':'0','categories':['Zum Einnehmen','Komplexmittel','Allergie & Heuschnupfen'],'categoryIds':['A001Z001','N001H001K001','N001P001A001'],'name':'Klosterfrau Allergin Globuli','price':959,'pzn':'04629775'},{'amount':'0','categories':['Loratadin'],'categoryIds':['A001L001'],'name':'Loratadin STADA allerg 10 mg','price':256,'pzn':'01592422'},{'amount':'0','categories':['Gereizte Haut','empfindliche Haut'],'categoryIds':['A001G002','KN001K001R001E001'],'name':'Eucerin pH5 Hautschutz Waschlotion','price':679,'pzn':'13889191'}];asdasd </script>"; // result will be an iterator over tuples containing the start and end indices for each match in the string let result = regex.captures_iter(string); for mat in result { println!("{:?}", mat); } }

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 Rust, please visit: https://docs.rs/regex/latest/regex/