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

/
/
g

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#"(?<=")[^"]+?\.xml(?=")"#).unwrap(); let string = "[],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z614,\"lanquage\":\"\",\"width\":1536,\"assetTypeIds\": [\"http://data.media.theplatform.eu/media/data/AssetType/4480581423\"],\"assetTypes\": xnfl AA' v x [\"hero_1536x614\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/4538437053\",\"streamingUrl\":\"httpzllmena-imq-cdn- lb.aws.playco.com/Sony/OUTLANDERYZO148028001/OUTLANDERY2014SOZEo01-1536x614-DHE.jpg\",\"protectionScheme\":\"\"}, {\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/114391621220\",\"downloadUrl\":\"\",\"releases\": [],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z324,\"lanquage\":\"\",\"width\":S76,\"assetTypeIds\":[\"http://data.media.theplatform.eulmedia/data/AssetType/7849541325\"],\"assetTypes\": [\"dsk_tab_screenshot_576x324\"1,\"serverId\":\"http://data.media.theplatform.eu/media/data/Server/4S38437053\",\"streamingUrl\":\"http://mena-img-cdn- lb.aws.playco.com/Sony/OUTLANDERYZO148028001/OUTLANDERY2014SOZEo01-576x324-LSD.jpg\",\"protectionScheme\":\"\"}, {\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/117352517052\",\"downloadUrl\":\"\",\"releases\": [],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z370,\"lanquage\":\"\",\"width\"z250,\"assetTypeIds\": [\"http://data.media.theplatform.eu/media/data/AssetType/14487621229\"],\"assetTypes\": [\"ooredoo_poster_25ox370_Proqram\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/11680325311\",\"streamingUrl\":\"http://distribution- ooredoo.83.amazonaws.com/Sony/EPISODES/STZ_OUTLANDERY20148028001/STZ_OUTLANDERY20148028001_25ox370_PST.jpg\",\"protectionScheme\":\"\"}, {\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/117352517066\",\"downloadUrl\":\"\",\"releases\": [],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z370,\"lanquage\":\"\",\"width\"z250,\"assetTypeIds\": [\"http://data.media.theplatform.eu/media/data/AssetType/14487621228\"],\"assetTypes\": [\"ooredoo_poster_25ox370_Season\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/l1680325311\",\"streamingUrl\":\"http://distribution- ooredoo.83.amazonaws.com/Sony/SERIES/STZ_OUTLANDERY2014802/STZ_OUTLANDERY2014802_25ox370_PST.jpg\",\"protectionScheme\":\"\"}]},{\"ratings\": [],\"mediaId\":\"http://data.media.theplatform.eu/media/data/Media/114389573291\",\"mediaTitle\":\"Je Suis Prest\",\"mediacuid\"z\"OUTLANDERY2014SOZEo09\",\"availableDate\":\"2016-07- 01T10:4lz\",\"content\":[{\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/114391109180\",\"downloadUrl\":\"\",\"releases\": [{\"pid\":\"chroPmeUeyk\",\"url\"z\"http://link.theplatform.eu/s/anAph/chroPmeUeyk\",\"restrictionld\":\"\"}],\"bitrate\":0,\"duration\":0.0,\"format\":\"Filmstrip\",\"height\":110,\"language\":\"en\",\"wid th\":199,\"assetTypeIds\":[\"http://data.media.theplatform.eu/media/data/AssetType/5416517342\"],\"assetTypes\": [\"filmstrip_199x110\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/4538437053\",\"streamingUrl\":\"http://mena-img-cdn- lb.aws.playco.com/Sony/OUTLANDERYZO148028009/OUTLANDERY2014SOZEo09.fs\",\"protectionScheme\":\"\"}, {\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/114446917184\",\"downloadUrl\":\"\",\"releases\": [{\"pid\":\"9pryBMkmeo\",\"url\"z\"http://link.theplatform.eu/s/anAph/QpryBMkmeo\",\"restrictionld\":\"\"}],\"bitrate\":0,\"duration\":0.0,\"format\":\"DFXP\",\"height\":0,\"lanquage\":\"ar\",\"width\":0,\" assetTypeIds\"z[\"http://data.media.theplatform.eu/media/data/AssetType/23575621096\"],\"assetTypes\"z[\"dfxp_ar_vu\"1,\"serverId\":\"\",\"streamingUrl\":\"http://mena-jit-cdn-lb.aws.playco.com/JIT/sony/OUTLANDERY2014S02E009/DRM/942f9636aea1289badf655d9f340cc65936e4660/OUTLANDERY2014S02E009.xml\" , \"protectionScheme\":\"\"},"; // 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/