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

const regex = new RegExp('{\\"vault\\":\\"{\\"data\\":\\"(.*)\\",\\"iv\\":\\"(.+)\\",\\"salt\\":\\"(.+)\\"}\\"}', 'gm') const str = `{"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`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions