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

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "(?<=\")[^\"]+?\\.xml(?=\")"; final String string = "[],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z614,\"lanquage\":\"\",\"width\":1536,\"assetTypeIds\":\n" + "[\"http://data.media.theplatform.eu/media/data/AssetType/4480581423\"],\"assetTypes\": xnfl AA' v x\n" + "[\"hero_1536x614\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/4538437053\",\"streamingUrl\":\"httpzllmena-imq-cdn-\n" + "lb.aws.playco.com/Sony/OUTLANDERYZO148028001/OUTLANDERY2014SOZEo01-1536x614-DHE.jpg\",\"protectionScheme\":\"\"},\n" + "{\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/114391621220\",\"downloadUrl\":\"\",\"releases\":\n" + "[],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z324,\"lanquage\":\"\",\"width\":S76,\"assetTypeIds\":[\"http://data.media.theplatform.eulmedia/data/AssetType/7849541325\"],\"assetTypes\":\n" + "[\"dsk_tab_screenshot_576x324\"1,\"serverId\":\"http://data.media.theplatform.eu/media/data/Server/4S38437053\",\"streamingUrl\":\"http://mena-img-cdn-\n" + "lb.aws.playco.com/Sony/OUTLANDERYZO148028001/OUTLANDERY2014SOZEo01-576x324-LSD.jpg\",\"protectionScheme\":\"\"},\n" + "{\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/117352517052\",\"downloadUrl\":\"\",\"releases\":\n" + "[],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z370,\"lanquage\":\"\",\"width\"z250,\"assetTypeIds\":\n" + "[\"http://data.media.theplatform.eu/media/data/AssetType/14487621229\"],\"assetTypes\":\n" + "[\"ooredoo_poster_25ox370_Proqram\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/11680325311\",\"streamingUrl\":\"http://distribution-\n" + "ooredoo.83.amazonaws.com/Sony/EPISODES/STZ_OUTLANDERY20148028001/STZ_OUTLANDERY20148028001_25ox370_PST.jpg\",\"protectionScheme\":\"\"},\n" + "{\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/117352517066\",\"downloadUrl\":\"\",\"releases\":\n" + "[],\"bitrate\":0,\"duration\":0.0,\"format\":\"JPEG\",\"height\"z370,\"lanquage\":\"\",\"width\"z250,\"assetTypeIds\":\n" + "[\"http://data.media.theplatform.eu/media/data/AssetType/14487621228\"],\"assetTypes\":\n" + "[\"ooredoo_poster_25ox370_Season\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/l1680325311\",\"streamingUrl\":\"http://distribution-\n" + "ooredoo.83.amazonaws.com/Sony/SERIES/STZ_OUTLANDERY2014802/STZ_OUTLANDERY2014802_25ox370_PST.jpg\",\"protectionScheme\":\"\"}]},{\"ratings\":\n" + "[],\"mediaId\":\"http://data.media.theplatform.eu/media/data/Media/114389573291\",\"mediaTitle\":\"Je Suis Prest\",\"mediacuid\"z\"OUTLANDERY2014SOZEo09\",\"availableDate\":\"2016-07-\n" + "01T10:4lz\",\"content\":[{\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/114391109180\",\"downloadUrl\":\"\",\"releases\":\n" + "[{\"pid\":\"chroPmeUeyk\",\"url\"z\"http://link.theplatform.eu/s/anAph/chroPmeUeyk\",\"restrictionld\":\"\"}],\"bitrate\":0,\"duration\":0.0,\"format\":\"Filmstrip\",\"height\":110,\"language\":\"en\",\"wid\n" + "th\":199,\"assetTypeIds\":[\"http://data.media.theplatform.eu/media/data/AssetType/5416517342\"],\"assetTypes\":\n" + "[\"filmstrip_199x110\"],\"serverId\"z\"http://data.media.theplatform.eu/media/data/Server/4538437053\",\"streamingUrl\":\"http://mena-img-cdn-\n" + "lb.aws.playco.com/Sony/OUTLANDERYZO148028009/OUTLANDERY2014SOZEo09.fs\",\"protectionScheme\":\"\"},\n" + "{\"id\"z\"http://data.media.theplatform.eu/media/data/MediaFile/114446917184\",\"downloadUrl\":\"\",\"releases\":\n" + "[{\"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,\"\n" + "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\":\"\"},"; final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html