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
No Match

r"
"
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){\"vault\":\"{\"data\":\"(.*)\",\"iv\":\"(.+)\",\"salt\":\"(.+)\"}\"}"#).unwrap(); let string = "{\"vault\":\"{\"data\":\"T0U8fp1y3siwwpTK+tsuoC3s/DfClS3l5RGa9XLbRW3fGFv5xLy2t9knSQrwXEvwEqV36RPIto1Nyn2br3QDtvyE4iKzXGjGk8R0m3SsHFekIR3FUoW4roN3dfkDFyYz/udTwUNVTaQYusUvI05HOrl5x5Q68WM+6wZbR74WlvpK84e2NeELRBvkZX6+hMAEpzguZfk3kds7/1e96yQuYnQc4j/4CYUKKTgUzDrs2Hnvz2iTvgiHrZu8IDc=\",\"iv\":\"n7wMnxUezwXxGmUSVwOKtg==\",\"salt\":\"E9tWReSeZnLzfOsawQ6XA4L3USy8/2OWOmbi6o/yU9c=\"}\"},\"NetworkController\":{\"network\":\"0x1\",\"networkMetadata\":{\"baseFeePerGas\":\"0x10fc587c58\",\"capabilities\":{\"EIP1559\":true}},\"provider\":{\"ticker\":\"ETH\",\"type\":\"mainnet\"}},\"PreferencesController\":{\"accountTokens\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":{\"goerli\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"kovan\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"mainnet\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"rinkeby\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"ropsten\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}]}},\"assetImages\":{\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\":null},\"batTokenAdded\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":true},\"completedOnboarding\":false,\"currentLocale\":\"en\",\"featureFlags\":{\"showIncomingTransactions\":true,\"transactionTime\":false},\"firstTimeFlowType\":null,\"forgottenPassword\":false,\"frequentRpcListDetail\":[],\"hardwareConnect\":false,\"hasNativeIPFSSupport\":false,\"identities\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":{\"address\":\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\",\"lastSelected\":1.634532760173e+12,\"name\":\"Account 1\"}},\"ipfsGateway\":\"dweb.link\",\"knownMethodData\":{},\"lostIdentities\":{},\"metaMetricsId\":null,\"metaMetricsSendCount\":0,\"participateInMetaMetrics\":null,\"preferences\":{\"shouldShowIPFSSection\":false,\"showFiatInTestnets\":false,\"useNativeCurrencyAsPrimaryCurrency\":true},\"selectedAddress\":\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\",\"suggestedTokens\":{},\"tokens\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"useBlockie\":false,\"useNonceField\":false,\"usePhishDetect\":true},\"config\":{},\"firstTimeInfo\":{\"date\":1.634532743225e+12,\"version\":\"0.0.0\"}}wdata{\"AlertController\":{\"alertEnabledness\":{\"invalidCustomNetwork\":true,\"unconnectedAccount\":true},\"unconnectedAccountAlertShownOrigins\":{}},\"CachedBalancesController\":{\"cachedBalances\":{\"0x1\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":\"0x0\"}}},\"CurrencyController\":{\"conversionDate\":1634532744.578,\"conversionRate\":3858.07,\"currentCurrency\":\"usd\",\"nativeCurrency\":\"ETH\",\"usdConversionRate\":0},\"IncomingTransactionsController\":{\"incomingTransactions\":{},\"incomingTxLastFetchedBlocksByNetwork\":{\"goerli\":null,\"kovan\":null,\"mainnet\":13439794,\"rinkeby\":null,\"ropsten\":null}},\"KeyringController\":{\"vault\":\"{\"data\":\"T0U8fp1y3siwwpTK+tsuoC3s/DfClS3l5RGa9XLbRW3fGFv5xLy2t9knSQrwXEvwEqV36RPIto1Nyn2br3QDtvyE4iKzXGjGk8R0m3SsHFekIR3FUoW4roN3dfkDFyYz/udTwUNVTaQYusUvI05HOrl5x5Q68WM+6wZbR74WlvpK84e2NeELRBvkZX6+hMAEpzguZfk3kds7/1e96yQuYnQc4j/4CYUKKTgUzDrs2Hnvz2iTvgiHrZu8IDc=\",\"iv\":\"n7wMnxUezwXxGmUSVwOKtg==\",\"salt\":\"E9tWReSeZnLzfOsawQ6XA4L3USy8/2OWOmbi6o/yU9c=\"}\"},\"NetworkController\":{\"network\":\"0x1\",\"networkMetadata\":{\"baseFeePerGas\":\"0x10fc587c58\",\"capabilities\":{\"EIP1559\":true}},\"provider\":{\"ticker\":\"ETH\",\"type\":\"mainnet\"}},\"On"; // 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/