Regular Expressions 101

Save & Share

  • Regex Version: ver. 38
  • 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 = "\"listItems\"\\s*:\\s*([^\\}]+)"; final String string = "\"listItems\": [\n" + " {\n" + " \"name\": \"Gelas Kaca Lusinan Murah 1 Set Isi 6 Motif Bening Model Klasik Unik Cafe Lucu Cantik Kedaung Coolant Tumblers Harga Murah Tidak Mudah Retak Pecah Bahan Beling Tebal Ukuran 250 ml elegan Untuk Tamu Rumah dan Dapur\",\n" + " \"nid\": \"5609668850\",\n" + " \"icons\": [],\n" + " \"image\": \"https://id-test-11.slatic.net/p/0227998499138451f7cc6ada1d885a7b.png\",\n" + " \"originalPrice\": \"35000.00\",\n" + " \"originalPriceShow\": \"Rp35.000\",\n" + " \"price\": \"29000.00\",\n" + " \"promotionId\": \"null\",\n" + " \"priceShow\": \"Rp29.000\",\n" + " \"discount\": \"-17%\",\n" + " \"ratingScore\": \"0\",\n" + " \"review\": \"\",\n" + " \"installment\": \"\",\n" + " \"tItemType\": \"nt_product\",\n" + " \"location\": \"Kota Surabaya\",\n" + " \"cheapest_sku\": \"5609668850_ID-11061072628\",\n" + " \"sku\": \"5609668850_ID\",\n" + " \"skus\": [],\n" + " \"brandId\": \"123222884\",\n" + " \"brandName\": \"KEDAUNG\",\n" + " \"sellerId\": \"400603179050\",\n" + " \"mainSellerId\": \"\",\n" + " \"sellerName\": \"Go-Panstore\",\n" + " \"thumbs\": [\n" + " {\n" + " \"image\": \"https://id-test-11.slatic.net/p/0227998499138451f7cc6ada1d885a7b.png\",\n" + " \"sku\": \"5609668850_ID\",\n" + " \"skuId\": \"11061072628\",\n" + " \"itemUrl\": \"/products/gelas-kaca-lusinan-murah-1-set-isi-6-motif-bening-model-klasik-unik-cafe-lucu-cantik-kedaung-coolant-tumblers-harga-murah-tidak-mudah-retak-pecah-bahan-beling-tebal-ukuran-250-ml-elegan-untuk-tamu-rumah-dan-dapur-i5609668850.html\"\n" + " }\n" + " ],\n" + " \"restrictedAge\": 0,\n" + " \"categories\": [\n" + " 16336,\n" + " 16358,\n" + " 16470\n" + " ],\n" + " \"clickTrace\": \"query:gelas+lucu+harga+murah;nid:5609668850;src:LazadaMainSrp;rn:c6e42d21e0c1c781d4df4ad08f2c5705;region:id;sku:5609668850_ID;price:29000.00;client:desktop;supplier_id:400603179050;asc_category_id:16470;item_id:5609668850;sku_id:11061072628;shop_id:2523734\",\n" + " \"addToCartSkus\": [\n" + " {\n" + " \"sku\": \"5609668850_ID-11061072628\",\n" + " \"skuId\": \"11061072628\",\n" + " \"count\": 0\n" + " }\n" + " ],\n" + " \"itemId\": \"5609668850\",\n" + " \"skuId\": \"11061072628\",\n" + " \"inStock\": true,\n" + " \"isAD\": 0,\n" + " \"addToCart\": false,\n" + " \"showFeedBack\": true,\n" + " \"longImageDisplayable\": false,\n" + " \"itemUrl\": \"//www.lazada.co.id/products/gelas-kaca-lusinan-murah-1-set-isi-6-motif-bening-model-klasik-unik-cafe-lucu-cantik-kedaung-coolant-tumblers-harga-murah-tidak-mudah-retak-pecah-bahan-beling-tebal-ukuran-250-ml-elegan-untuk-tamu-rumah-dan-dapur-i5609668850.html\",\n" + " \"querystring\": \"search=1\"\n" + " },\n" + " {\n" + " \"name\": \"Gelas Kaca Lusinan Murah 1 Set Isi 6 Motif Bening Model Cawan Unik Cafe Lucu Cantik Merk Kedaung Harga Murah Tidak Mudah Retak Pecah Bahan Beling Tebal Ukuran 250 ml elegan Untuk Tamu Rumah dan Dapur\",\n" + " \"nid\": \"5578244948\",\n" + " \"icons\": [],\n" + " \"image\": \"https://id-test-11.slatic.net/p/f3c88eb266396b1a132413af364c5e97.png\",\n" + " \"originalPrice\": \"35000.00\",\n" + " \"originalPriceShow\": \"Rp35.000\",\n" + " \"price\": \"25000.00\",\n" + " \"promotionId\": \"null\",\n" + " \"priceShow\": \"Rp25.000\",\n" + " \"discount\": \"-29%\",\n" + " \"ratingScore\": \"0\",\n" + " \"review\": \"\",\n" + " \"installment\": \"\",\n" + " \"tItemType\": \"nt_product\",\n" + " \"location\": \"Kota Surabaya\",\n" + " \"cheapest_sku\": \"5578244948_ID-11032256617\",\n" + " \"sku\": \"5578244948_ID\",\n" + " \"skus\": [],\n" + " \"brandId\": \"123222884\",\n" + " \"brandName\": \"KEDAUNG\",\n" + " \"sellerId\": \"400603179050\",\n" + " \"mainSellerId\": \"\",\n" + " \"sellerName\": \"Go-Panstore\",\n" + " \"thumbs\": [\n" + " {\n" + " \"image\": \"https://id-test-11.slatic.net/p/f3c88eb266396b1a132413af364c5e97.png\",\n" + " \"sku\": \"5578244948_ID\",\n" + " \"skuId\": \"11032256617\",\n" + " \"itemUrl\": \"/products/gelas-kaca-lusinan-murah-1-set-isi-6-motif-bening-model-cawan-unik-cafe-lucu-cantik-merk-kedaung-harga-murah-tidak-mudah-retak-pecah-bahan-beling-tebal-ukuran-250-ml-elegan-untuk-tamu-rumah-dan-dapur-i5578244948.html\"\n" + " }\n" + " ],\n" + " \"restrictedAge\": 0,\n" + " \"categories\": [\n" + " 16336,\n" + " 16358,\n" + " 16470\n" + " ],\n" + " \"clickTrace\": \"query:gelas+lucu+harga+murah;nid:5578244948;src:LazadaMainSrp;rn:c6e42d21e0c1c781d4df4ad08f2c5705;region:id;sku:5578244948_ID;price:25000.00;client:desktop;supplier_id:400603179050;asc_category_id:16470;item_id:5578244948;sku_id:11032256617;shop_id:2523734\",\n" + " \"addToCartSkus\": [\n" + " {\n" + " \"sku\": \"5578244948_ID-11032256617\",\n" + " \"skuId\": \"11032256617\",\n" + " \"count\": 0\n" + " }\n" + " ],\n" + " \"itemId\": \"5578244948\",\n" + " \"skuId\": \"11032256617\",\n" + " \"inStock\": true,\n" + " \"isAD\": 0,\n" + " \"addToCart\": false,\n" + " \"showFeedBack\": true,\n" + " \"longImageDisplayable\": false,\n" + " \"itemUrl\": \"//www.lazada.co.id/products/gelas-kaca-lusinan-murah-1-set-isi-6-motif-bening-model-cawan-unik-cafe-lucu-cantik-merk-kedaung-harga-murah-tidak-mudah-retak-pecah-bahan-beling-tebal-ukuran-250-ml-elegan-untuk-tamu-rumah-dan-dapur-i5578244948.html\",\n" + " \"querystring\": \"search=1\"\n" + " },\n" + " {\n" + " \"name\": \"Gelas Kaca Lusinan Murah 1 Set Isi 6 Motif Bening Model WHISKEY Unik Cafe Lucu Cantik Merk Kedaung Harga Murah Tidak Mudah Retak Pecah Bahan Beling Tebal Ukuran 250 ml elegan Untuk Tamu Rumah dan Dapur\",\n" + " \"nid\": \"5578230424\",\n" + " \"icons\": [],\n" + " \"image\": \"https://id-test-11.slatic.net/p/df5706ad4c4a457e61b6875b1190aad9.png\",\n" + " \"originalPrice\": \"48000.00\",\n" + " \"originalPriceShow\": \"Rp48.000\",\n" + " \"price\": \"39000.00\",\n" + " \"promotionId\": \"null\",\n" + " \"priceShow\": \"Rp39.000\",\n" + " \"discount\": \"-19%\",\n" + " \"ratingScore\": \"5.0\",\n" + " \"review\": \"2\",\n" + " \"installment\": \"\",\n" + " \"tItemType\": \"nt_product\",\n" + " \"location\": \"Kota Surabaya\",\n" + " \"cheapest_sku\": \"5578230424_ID-11032234543\",\n" + " \"sku\": \"5578230424_ID\",\n" + " \"skus\": [],\n" + " \"brandId\": \"123222884\",\n" + " \"brandName\": \"KEDAUNG\",\n" + " \"sellerId\": \"400603179050\",\n" + " \"mainSellerId\": \"\",\n" + " \"sellerName\": \"Go-Panstore\",\n" + " \"thumbs\": [\n" + " {\n" + " \"image\": \"https://id-test-11.slatic.net/p/df5706ad4c4a457e61b6875b1190aad9.png\",\n" + " \"sku\": \"5578230424_ID\",\n" + " \"skuId\": \"11032234543\",\n" + " \"itemUrl\": \"/products/gelas-kaca-lusinan-murah-1-set-isi-6-motif-bening-model-whiskey-unik-cafe-lucu-cantik-merk-kedaung-harga-murah-tidak-mudah-retak-pecah-bahan-beling-tebal-ukuran-250-ml-elegan-untuk-tamu-rumah-dan-dapur-i5578230424.html\"\n" + " }\n" + " ],\n" + " \"restrictedAge\": 0,\n" + " \"categories\": [\n" + " 16336,\n" + " 16358,\n" + " 16470\n" + " ],\n" + " \"clickTrace\": \"query:gelas+lucu+harga+murah;nid:5578230424;src:LazadaMainSrp;rn:c6e42d21e0c1c781d4df4ad08f2c5705;region:id;sku:5578230424_ID;price:39000.00;client:desktop;supplier_id:400603179050;asc_category_id:16470;item_id:5578230424;sku_id:11032234543;shop_id:2523734\",\n" + " \"addToCartSkus\": [\n" + " {\n" + " \"sku\": \"5578230424_ID-11032234543\",\n" + " \"skuId\": \"11032234543\",\n" + " \"count\": 0\n" + " }\n" + " ],\n" + " \"itemId\": \"5578230424\",\n" + " \"skuId\": \"11032234543\",\n" + " \"inStock\": true,\n" + " \"isAD\": 0,\n" + " \"addToCart\": false,\n" + " \"showFeedBack\": true,\n" + " \"longImageDisplayable\": false,\n" + " \"itemUrl\": \"//www.lazada.co.id/products/gelas-kaca-lusinan-murah-1-set-isi-6-motif-bening-model-whiskey-unik-cafe-lucu-cantik-merk-kedaung-harga-murah-tidak-mudah-retak-pecah-bahan-beling-tebal-ukuran-250-ml-elegan-untuk-tamu-rumah-dan-dapur-i5578230424.html\",\n" + " \"querystring\": \"search=1\"\n" + " },\n" + " {\n" + " \"name\": \"GODJILLA Gelas Cafe Viral Bahan Kaca Bening Cantik Kedaung Drink Jar Harvest 250 ml Set lengkap dengan tutup Stainless dan gagang Aesthetic Lucu Elegan Harga Termurah\",\n" + " \"nid\": \"6413930218\",\n" + " \"icons\": [],\n" + " \"image\": \"https://sg-test-11.slatic.net/p/532045a7c119addbf91e6150d2a441b9.png\",\n" + " \"price\": \"12690.00\",\n" + " \"promotionId\": \"null\",\n" + " \"priceShow\": \"Rp12.690\",\n" + " \"ratingScore\": \"0\",\n" + " \"review\": \"\",\n" + " \"installment\": \"\",\n" + " \"tItemType\": \"nt_product\",\n" + " \"location\": \"Kota Surabaya\",\n" + " \"cheapest_sku\": \"6413930218_ID-12164780997\",\n" + " \"sku\": \"6413930218_ID\",\n" + " \"skus\": [],\n" + " \"brandId\": \"123222884\",\n" + " \"brandName\": \"KEDAUNG\",\n" + " \"sellerId\": \"400625169008\",\n" + " \"mainSellerId\": \"\",\n" + " \"sellerName\": \"Godjilla Online Store\",\n" + " \"thumbs\": [\n" + " {\n" + " \"image\": \"https://sg-live-01.slatic.net/p/cdbfe36dca8c1c5a62f84133ece4966c.jpg\",\n" + " \"sku\": \"6413930218_ID\",\n" + " \"skuId\": \"12164780997\",\n" + " \"itemUrl\": \"/products/godjilla-gelas-cafe-viral-bahan-kaca-bening-cantik-kedaung-drink-jar-harvest-250-ml-set-lengkap-dengan-tutup-stainless-dan-gagang-aesthetic-lucu-elegan-harga-termurah-i6413930218.html\"\n" + " }\n" + " ],\n" + " \"restrictedAge\": 0,\n" + " \"categories\": [\n" + " 16336,\n" + " 16358,\n" + " 16470\n" + " ],\n" + " \"clickTrace\": \"query:gelas+lucu+harga+murah;nid:6413930218;src:LazadaMainSrp;rn:c6e42d21e0c1c781d4df4ad08f2c5705;region:id;sku:6413930218_ID;price:12690.00;client:desktop;supplier_id:400625169008;asc_category_id:16470;item_id:6413930218;sku_id:12164780997;shop_id:4388985\",\n" + " \"addToCartSkus\": [\n" + " {\n" + " \"sku\": \"6413930218_ID-12164780997\",\n" + " \"skuId\": \"12164780997\",\n" + " \"count\": 0\n" + " }\n" + " ],\n" + " \"itemId\": \"6413930218\",\n" + " \"skuId\": \"12164780997\",\n" + " \"inStock\": true,\n" + " \"isAD\": 0,\n" + " \"addToCart\": false,\n" + " \"showFeedBack\": true,\n" + " \"longImageDisplayable\": false,\n" + " \"itemUrl\": \"//www.lazada.co.id/products/godjilla-gelas-cafe-viral-bahan-kaca-bening-cantik-kedaung-drink-jar-harvest-250-ml-set-lengkap-dengan-tutup-stainless-dan-gagang-aesthetic-lucu-elegan-harga-termurah-i6413930218.html\",\n" + " \"querystring\": \"search=1\"\n" + " },\n" + " {\n" + " \"name\": \"GODJILLA Gelas Cafe Viral Bahan Kaca Bening Cantik 3 pcs Kedaung Drink Jar Harvest 250 ml Set lengkap dengan tutup Stainless dan gagang Aesthetic Lucu Elegan Harga Termurah\",\n" + " \"nid\": \"6348904497\",\n" + " \"icons\": [],\n" + " \"image\": \"https://sg-test-11.slatic.net/p/d46be3e12d672790397a73b0bb957972.png\",\n" + " \"originalPrice\": \"33000.00\",\n" + " \"originalPriceShow\": \"Rp33.000\",\n" + " \"price\": \"30500.00\",\n" + " \"promotionId\": \"null\",\n" + " \"priceShow\": \"Rp30.500\",\n" + " \"discount\": \"-8%\",\n" + " \"ratingScore\": \"0\",\n" + " \"review\": \"\",\n" + " \"installment\": \"\",\n" + " \"tItemType\": \"nt_product\",\n" + " \"location\": \"Kota Surabaya\",\n" + " \"cheapest_sku\": \"6348904497_ID-12043432935\",\n" + " \"sku\": \"6348904497_ID\",\n" + " \"skus\": [],\n" + " \"brandId\": \"123222884\",\n" + " \"brandName\": \"KEDAUNG\",\n" + " \"sellerId\": \"400625169008\",\n" + " \"mainSellerId\": \"\",\n" + " \"sellerName\": \"Godjilla Online Store\",\n" + " \"thumbs\": [\n" + " {\n" + " \"image\": \"https://sg-test-11.slatic.net/p/d46be3e12d672790397a73b0bb957972.png\",\n" + " \"sku\": \"6348904497_ID\",\n" + " \"skuId\": \"12043432935\",\n" + " \"itemUrl\": \"/products/godjilla-gelas-cafe-viral-bahan-kaca-bening-cantik-3-pcs-kedaung-drink-jar-harvest-250-ml-set-lengkap-dengan-tutup-stainless-dan-gagang-aesthetic-lucu-elegan-harga-termurah-i6348904497.html\"\n" + " },\n" + " {\n" + " \"image\": \"https://sg-test-11.slatic.net/p/d46be3e12d672790397a73b0bb957972.png\",\n" + " \"sku\": \"6348904497_ID\",\n" + " \"skuId\": \"12043432934\",\n" + " \"itemUrl\": \"/products/godjilla-gelas-cafe-viral-bahan-kaca-bening-cantik-3-pcs-kedaung-drink-jar-harvest-250-ml-set-lengkap-dengan-tutup-stainless-dan-gagang-aesthetic-lucu-elegan-harga-termurah-i6348904497.html\"\n" + " }\n" + " ],\n" + " \"restrictedAge\": 0,\n" + " \"categories\": [\n" + " 16336,\n" + " 16358,\n" + " 16470\n" + " ],\n" + " \"clickTrace\": \"query:gelas+lucu+harga+murah;nid:6348904497;src:LazadaMainSrp;rn:c6e42d21e0c1c781d4df4ad08f2c5705;region:id;sku:6348904497_ID;price:30500.00;client:desktop;supplier_id:400625169008;asc_category_id:16470;item_id:6348904497;sku_id:12043432935;shop_id:4388985\",\n" + " \"addToCartSkus\": [\n" + " {\n" + " \"sku\": \"6348904497_ID-12043432935\",\n" + " \"skuId\": \"12043432935\",\n" + " \"count\": 0\n" + " }\n" + " ],\n" + " \"itemId\": \"6348904497\",\n" + " \"skuId\": \"12043432935\",\n" + " \"inStock\": true,\n" + " \"isAD\": 0,\n" + " \"addToCart\": false,\n" + " \"showFeedBack\": true,\n" + " \"longImageDisplayable\": false,\n" + " \"itemUrl\": \"//www.lazada.co.id/products/godjilla-gelas-cafe-viral-bahan-kaca-bening-cantik-3-pcs-kedaung-drink-jar-harvest-250-ml-set-lengkap-dengan-tutup-stainless-dan-gagang-aesthetic-lucu-elegan-harga-termurah-i6348904497.html\",\n" + " \"querystring\": \"search=1\"\n" + " }\n" + " ],"; 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