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)(?:(^[^\[]+\[\s+)\{\s+\"id\"\:|(,\s+)\{\s+\"id\"\:)"#).unwrap(); let string = "{ \"status\": { \"timestamp\": \"2018-10-10T23:40:26.101Z\", \"error_code\": 0, \"error_message\": null, \"elapsed\": 14, \"credit_count\": 1 }, \"data\": [ { \"id\": 1, \"name\": \"Bitcoin\", \"symbol\": \"BTC\", \"slug\": \"bitcoin\", \"circulating_supply\": 17315325, \"total_supply\": 17315325, \"max_supply\": 21000000, \"date_added\": \"2013-04-28T00:00:00.000Z\", \"num_market_pairs\": 6324, \"cmc_rank\": 1, \"last_updated\": \"2018-10-10T23:39:30.000Z\", \"quote\": { \"USD\": { \"price\": 6593.07839577, \"volume_24h\": 3781676977.17942, \"percent_change_1h\": 0.299567, \"percent_change_24h\": -0.633751, \"percent_change_7d\": 0.95377, \"market_cap\": 114161295173.23618, \"last_updated\": \"2018-10-10T23:39:30.000Z\" } } }, { \"id\": 1027, \"name\": \"Ethereum\", \"symbol\": \"ETH\", \"slug\": \"ethereum\", \"circulating_supply\": 102492584.749, \"total_supply\": 102492584.749, \"max_supply\": null, \"date_added\": \"2015-08-07T00:00:00.000Z\", \"num_market_pairs\": 4471, \"cmc_rank\": 2, \"last_updated\": \"2018-10-10T23:39:42.000Z\", \"quote\": { \"USD\": { \"price\": 225.917892111, \"volume_24h\": 1382931374.09404, \"percent_change_1h\": 0.569086, \"percent_change_24h\": -0.704234, \"percent_change_7d\": 1.85499, \"market_cap\": 23154908703.502106, \"last_updated\": \"2018-10-10T23:39:42.000Z\" } } }, { \"id\": 52, \"name\": \"XRP\", \"symbol\": \"XRP\", \"slug\": \"ripple\", \"circulating_supply\": 39997634397, \"total_supply\": 99991817275, \"max_supply\": 100000000000, \"date_added\": \"2013-08-04T00:00:00.000Z\", \"num_market_pairs\": 230, \"cmc_rank\": 3, \"last_updated\": \"2018-10-10T23:40:09.000Z\", \"quote\": { \"USD\": { \"price\": 0.461478997819, \"volume_24h\": 411665959.164198, \"percent_change_1h\": 0.445149, \"percent_change_24h\": -3.5819, \"percent_change_7d\": -13.0624, \"market_cap\": 18458068236.65832, \"last_updated\": \"2018-10-10T23:40:09.000Z\" } } }, { \"id\": 1831, \"name\": \"Bitcoin Cash\", \"symbol\": \"BCH\", \"slug\": \"bitcoin-cash\", \"circulating_supply\": 17395525, \"total_supply\": 17395525, \"max_supply\": 21000000, \"date_added\": \"2017-07-23T00:00:00.000Z\", \"num_market_pairs\": 342, \"cmc_rank\": 4, \"last_updated\": \"2018-10-10T23:39:36.000Z\", \"quote\": { \"USD\": { \"price\": 512.630430925, \"volume_24h\": 369198906.22134, \"percent_change_1h\": 0.365485, \"percent_change_24h\": -0.745641, \"percent_change_7d\": -1.26889, \"market_cap\": 8917475476.91661, \"last_updated\": \"2018-10-10T23:39:36.000Z\" } } }, { \"id\": 1765, \"name\": \"EOS\", \"symbol\": \"EOS\", \"slug\": \"eos\", \"circulating_supply\": 906245117.6, \"total_supply\": 1006245119.9339, \"max_supply\": null, \"date_added\": \"2017-07-01T00:00:00.000Z\", \"num_market_pairs\": 174, \"cmc_rank\": 5, \"last_updated\": \"2018-10-10T23:39:36.000Z\", \"quote\": { \"USD\": { \"price\": 5.88204493255, \"volume_24h\": 532584590.023657, \"percent_change_1h\": 0.326144, \"percent_change_24h\": -0.205986, \"percent_change_7d\": 4.79873, \"market_cap\": 5330574501.627259, \"last_updated\": \"2018-10-10T23:39:36.000Z\" } } }, { \"id\": 512, \"name\": \"Stellar\", \"symbol\": \"XLM\", \"slug\": \"stellar\", \"circulating_supply\": 18890616791.6665, \"total_supply\": 104363617748.491, \"max_supply\": null, \"date_added\": \"2014-08-05T00:00:00.000Z\", \"num_market_pairs\": 120, \"cmc_rank\": 6, \"last_updated\": \"2018-10-10T23:39:19.000Z\", \"quote\": { \"USD\": { \"price\": 0.241243489647, \"volume_24h\": 40002371.0719364, \"percent_change_1h\": 0.417773, \"percent_change_24h\": -1.36287, \"percent_change_7d\": -0.740479, \"market_cap\": 4557238316.405842, \"last_updated\": \"2018-10-10T23:39:19.000Z\" } } },"; // 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/