Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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
No Match

/
/
gm

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"""title"":\s*""([^""]*)"".*?""weight"":\s*([0-9]+)"; string input = @"[ { ""json"": ""[\n {\n \""data\"": {\n \""product\"": {\n \""id\"": 23349897,\n \""created_at\"": \""2022-12-15T10:38:48+00:00\"",\n \""updated_at\"": \""2024-10-06T18:14:29+00:00\"",\n \""source\"": \""Reseller\"",\n \""source_ref\"": \""SUPPRIMER1\"",\n \""user_ref\"": \""EXT17\"",\n \""stock\"": 541,\n \""ean13\"": \""9780201379648\"",\n \""title\"": \""Instant Boost Botox\"",\n \""location\"": \""\"",\n \""picture_url\"": \""https://cdn.shopify.com/s/files/1/0083/9886/4480/products/image_600x.png?v=1674466007\"",\n \""weight\"": 640,\n \""height\"": null,\n \""length\"": null,\n \""width\"": null,\n \""unit_volume\"": null,\n \""stock_volume_in_m3\"": null,\n \""hs_code\"": \""33059000\"",\n \""supplier\"": null,\n \""pack_components\"": [],\n \""pack_product_ids\"": [],\n \""product_logistic_units\"": [],\n \""eco_tax_cents\"": \""0.0\"",\n \""eco_tax_currency\"": null,\n \""tax_rate\"": null,\n \""other_ref1\"": null,\n \""other_ref2\"": null,\n \""other_ref3\"": null,\n \""other_ref4\"": null,\n \""other_ref5\"": null,\n \""other_ref6\"": null,\n \""other_ref7\"": null,\n \""other_ref8\"": null,\n \""other_ref9\"": null,\n \""other_ref10\"": null,\n \""other_ref11\"": null,\n \""other_ref12\"": null,\n \""other_ref13\"": null,\n \""other_ref14\"": null,\n \""other_ref15\"": null,\n \""additional_references\"": [],\n \""total_physical_stock\"": 0,\n \""supplier_product_ids\"": [],\n \""product_additional_fields\"": [\n {\n \""id\"": 1284855,\n \""created_at\"": \""2024-02-16T10:16:38+00:00\"",\n \""updated_at\"": \""2024-02-16T10:16:38+00:00\"",\n \""product_id\"": 23349897,\n \""key\"": \""customOriginCountry\"",\n \""value\"": \""FR\""\n }\n ],\n \""product_instructions_files\"": []\n }\n },\n \""quantity\"": 1,\n \""product_user_ref\"": \""EXT17\""\n },\n {\n \""data\"": {\n \""product\"": {\n \""id\"": 23349890,\n \""created_at\"": \""2022-12-15T10:38:47+00:00\"",\n \""updated_at\"": \""2024-10-06T17:09:47+00:00\"",\n \""source\"": \""Manual product\"",\n \""source_ref\"": \""EXT08\"",\n \""user_ref\"": \""EXT08\"",\n \""stock\"": 1567,\n \""ean13\"": \""9780201349870\"",\n \""title\"": \""Shampoing Bain de Soie\"",\n \""location\"": \""\"",\n \""picture_url\"": \""https://cdn.shopify.com/s/files/1/0083/9886/4480/products/SHAMPOOINGPRE-FORME_39_600x.png?v=1668241257\"",\n \""weight\"": 370,\n \""height\"": null,\n \""length\"": null,\n \""width\"": null,\n \""unit_volume\"": null,\n \""stock_volume_in_m3\"": null,\n \""hs_code\"": \""33059000\"",\n \""supplier\"": null,\n \""pack_components\"": [],\n \""pack_product_ids\"": [],\n \""product_logistic_units\"": [],\n \""eco_tax_cents\"": \""0.0\"",\n \""eco_tax_currency\"": \""EUR\"",\n \""tax_rate\"": null,\n \""other_ref1\"": null,\n \""other_ref2\"": null,\n \""other_ref3\"": null,\n \""other_ref4\"": null,\n \""other_ref5\"": null,\n \""other_ref6\"": null,\n \""other_ref7\"": null,\n \""other_ref8\"": null,\n \""other_ref9\"": null,\n \""other_ref10\"": null,\n \""other_ref11\"": null,\n \""other_ref12\"": null,\n \""other_ref13\"": null,\n \""other_ref14\"": null,\n \""other_ref15\"": null,\n \""additional_references\"": [],\n \""total_physical_stock\"": 0,\n \""supplier_product_ids\"": [],\n \""product_additional_fields\"": [\n {\n \""id\"": 1087243,\n \""created_at\"": \""2023-06-08T13:55:58+00:00\"",\n \""updated_at\"": \""2023-06-08T13:55:58+00:00\"",\n \""product_id\"": 23349890,\n \""key\"": \""customOriginCountry\"",\n \""value\"": \""IT\""\n }\n ],\n \""product_instructions_files\"": []\n }\n },\n \""quantity\"": 1,\n \""product_user_ref\"": \""EXT08\""\n },\n {\n \""data\"": {\n \""product\"": {\n \""id\"": 23349893,\n \""created_at\"": \""2022-12-15T10:38:48+00:00\"",\n \""updated_at\"": \""2024-10-06T17:09:47+00:00\"",\n \""source\"": \""Manual product\"",\n \""source_ref\"": \""EXT09\"",\n \""user_ref\"": \""EXT09\"",\n \""stock\"": 623,\n \""ean13\"": \""3700605869374\"",\n \""title\"": \""Masque profond Bain de Soie\"",\n \""location\"": \""\"",\n \""picture_url\"": \""https://cdn.shopify.com/s/files/1/0083/9886/4480/products/SHAMPOOINGPRE-FORME_40_600x.png?v=1668241226\"",\n \""weight\"": 365,\n \""height\"": null,\n \""length\"": null,\n \""width\"": null,\n \""unit_volume\"": null,\n \""stock_volume_in_m3\"": null,\n \""hs_code\"": \""33059000\"",\n \""supplier\"": null,\n \""pack_components\"": [],\n \""pack_product_ids\"": [],\n \""product_logistic_units\"": [],\n \""eco_tax_cents\"": \""0.0\"",\n \""eco_tax_currency\"": \""EUR\"",\n \""tax_rate\"": null,\n \""other_ref1\"": null,\n \""other_ref2\"": null,\n \""other_ref3\"": null,\n \""other_ref4\"": null,\n \""other_ref5\"": null,\n \""other_ref6\"": null,\n \""other_ref7\"": null,\n \""other_ref8\"": null,\n \""other_ref9\"": null,\n \""other_ref10\"": null,\n \""other_ref11\"": null,\n \""other_ref12\"": null,\n \""other_ref13\"": null,\n \""other_ref14\"": null,\n \""other_ref15\"": null,\n \""additional_references\"": [],\n \""total_physical_stock\"": 0,\n \""supplier_product_ids\"": [],\n \""product_additional_fields\"": [\n {\n \""id\"": 1087245,\n \""created_at\"": \""2023-06-08T13:55:58+00:00\"",\n \""updated_at\"": \""2023-06-08T13:55:58+00:00\"",\n \""product_id\"": 23349893,\n \""key\"": \""customOriginCountry\"",\n \""value\"": \""IT\""\n }\n ],\n \""product_instructions_files\"": []\n }\n },\n \""quantity\"": 1,\n \""product_user_ref\"": \""EXT09\""\n },\n {\n \""data\"": {\n \""product\"": {\n \""id\"": 23349896,\n \""created_at\"": \""2022-12-15T10:38:48+00:00\"",\n \""updated_at\"": \""2024-10-06T15:00:55+00:00\"",\n \""source\"": \""Reseller\"",\n \""source_ref\"": \""EXT13\"",\n \""user_ref\"": \""EXT13\"",\n \""stock\"": 291,\n \""ean13\"": \""9780201379648\"",\n \""title\"": \""Elixir N°1 Réparation\"",\n \""location\"": \""\"",\n \""picture_url\"": \""https://cdn.shopify.com/s/files/1/0083/9886/4480/files/mescheveuxsontuneextensiondequijesuis_13_600x.png?v=1684941023\"",\n \""weight\"": 200,\n \""height\"": null,\n \""length\"": null,\n \""width\"": null,\n \""unit_volume\"": null,\n \""stock_volume_in_m3\"": null,\n \""hs_code\"": \""33059000\"",\n \""supplier\"": null,\n \""pack_components\"": [],\n \""pack_product_ids\"": [],\n \""product_logistic_units\"": [],\n \""eco_tax_cents\"": \""0.0\"",\n \""eco_tax_currency\"": null,\n \""tax_rate\"": null,\n \""other_ref1\"": null,\n \""other_ref2\"": null,\n \""other_ref3\"": null,\n \""other_ref4\"": null,\n \""other_ref5\"": null,\n \""other_ref6\"": null,\n \""other_ref7\"": null,\n \""other_ref8\"": null,\n \""other_ref9\"": null,\n \""other_ref10\"": null,\n \""other_ref11\"": null,\n \""other_ref12\"": null,\n \""other_ref13\"": null,\n \""other_ref14\"": null,\n \""other_ref15\"": null,\n \""additional_references\"": [],\n \""total_physical_stock\"": 0,\n \""supplier_product_ids\"": [],\n \""product_additional_fields\"": [\n {\n \""id\"": 1284861,\n \""created_at\"": \""2024-02-16T10:16:38+00:00\"",\n \""updated_at\"": \""2024-02-16T10:16:38+00:00\"",\n \""product_id\"": 23349896,\n \""key\"": \""customOriginCountry\"",\n \""value\"": \""FR\""\n }\n ],\n \""product_instructions_files\"": []\n }\n },\n \""quantity\"": 1,\n \""product_user_ref\"": \""EXT13\""\n },\n {\n \""data\"": {\n \""product\"": {\n \""id\"": 23349901,\n \""created_at\"": \""2022-12-15T10:38:48+00:00\"",\n \""updated_at\"": \""2024-10-06T15:00:55+00:00\"",\n \""source\"": \""Reseller\"",\n \""source_ref\"": \""SUPPRIMER\"",\n \""user_ref\"": \""EXT18\"",\n \""stock\"": 1299,\n \""ean13\"": \""9780201379044\"",\n \""title\"": \""Dream Protect\"",\n \""location\"": \""\"",\n \""picture_url\"": \""https://cdn.shopify.com/s/files/1/0083/9886/4480/files/mescheveuxsontuneextensiondequijesuis_16_600x.png?v=1684944604\"",\n \""weight\"": 200,\n \""height\"": null,\n \""length\"": null,\n \""width\"": null,\n \""unit_volume\"": null,\n \""stock_volume_in_m3\"": null,\n \""hs_code\"": \""63023100\"",\n \""supplier\"": \""\"",\n \""pack_components\"": [],\n \""pack_product_ids\"": [],\n \""product_logistic_units\"": [],\n \""eco_tax_cents\"": \""0.0\"",\n \""eco_tax_currency\"": null,\n \""tax_rate\"": null,\n \""other_ref1\"": null,\n \""other_ref2\"": null,\n \""other_ref3\"": null,\n \""other_ref4\"": null,\n \""other_ref5\"": null,\n \""other_ref6\"": null,\n \""other_ref7\"": null,\n \""other_ref8\"": null,\n \""other_ref9\"": null,\n \""other_ref10\"": null,\n \""other_ref11\"": null,\n \""other_ref12\"": null,\n \""other_ref13\"": null,\n \""other_ref14\"": null,\n \""other_ref15\"": null,\n \""additional_references\"": [],\n \""total_physical_stock\"": 0,\n \""supplier_product_ids\"": [],\n \""product_additional_fields\"": [\n {\n \""id\"": 1284864,\n \""created_at\"": \""2024-02-16T10:16:38+00:00\"",\n \""updated_at\"": \""2024-02-16T10:16:38+00:00\"",\n \""product_id\"": 23349901,\n \""key\"": \""customOriginCountry\"",\n \""value\"": \""FR\""\n }\n ],\n \""product_instructions_files\"": []\n }\n },\n \""quantity\"": 1,\n \""product_user_ref\"": \""EXT18\""\n }\n]"" } ]"; RegexOptions options = RegexOptions.Multiline; foreach (Match m in Regex.Matches(input, pattern, options)) { Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index); } } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx