Regular Expressions 101

Save & Share

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)^\s+\"#{prefix}\.(.+)\":"##).unwrap(); let string = "\"use strict\" define -> launchOptions = (prefix) -> options = \"#{prefix}.businessCredits.businessBudgetFacility\": functionDetails: functionId : \"be.kbc.businessCredits.businessBudgetFacility\", mode: \"create\" \"#{prefix}.businessCredits.taxPrepaymentPlan\": functionDetails: functionId : \"be.kbc.businessCredits.taxPrepaymentPlan\", mode: \"create\" \"#{prefix}.credits.privateCreditCardRequest.update\": functionDetails: functionId : \"be.kbc.credits.privateCreditCardRequest\", mode: \"update\" \"#{prefix}.credits.homeAtOnce\": functionDetails: functionId : \"be.kbc.credits.homeAtOnce\", mode: \"createRequest\" \"#{prefix}.credits.homeAtOnce.detailRequest\": functionDetails: functionId : \"be.kbc.credits.homeAtOnce\", mode: \"detailRequest\" \"#{prefix}.credits.homeAtOnce.editRequest\": functionDetails: functionId : \"be.kbc.credits.homeAtOnce\", mode: \"editRequest\" \"#{prefix}.credits.homeAtOnce.updateRequest\": functionDetails: functionId : \"be.kbc.credits.homeAtOnce\", mode: \"updateRequest\" \"#{prefix}.credits.budgetfacilitylight\": functionDetails: functionId : \"be.kbc.credits.budgetFacilityLight\", mode: \"create\" \"#{prefix}.credits.loaRequest\": functionDetails: functionId : \"be.kbc.credits.loaRequest\", mode: \"create\" \"#{prefix}.credits.loaRequest.update\": functionDetails: functionId : \"be.kbc.credits.loaRequest\", mode: \"update\" \"#{prefix}.doccle.doccleAccount\": functionDetails: functionId : \"be.kbc.doccle.doccleAccount\", mode: \"create\" \"#{prefix}.esigning.esigning\": functionDetails: functionId : \"be.kbc.esigning.esigning\", mode: \"create\" \"#{prefix}.esigning.esigning.createBundle\": functionDetails: functionId : \"be.kbc.esigning.esigning\", mode: \"createBundle\" \"#{prefix}.home.dinoHomeInsurance\": functionDetails: functionId : \"be.kbc.home.dinoHomeInsurance\", mode: \"create\" \"#{prefix}.home.energyRenovationAdvice\": functionDetails: functionId : \"be.kbc.home.era\", mode: \"create\" \"#{prefix}.insurances.smallProducts\": functionDetails: functionId : \"be.kbc.insurances.smallProducts\", mode: \"create\" \"#{prefix}.insurances.smallproducts.external\": functionDetails: functionId : \"be.kbc.insurances.smallProducts\", mode: \"create\" \"#{prefix}.insurances.insurancesUpsell\": functionDetails: functionId : \"be.kbc.insurances.insurancesUpsell\", mode: \"create\" \"#{prefix}.investments.buycooperativeshares\": functionDetails: functionId : \"be.kbc.investments.buyCooperativeShares\", mode: \"create\" \"#{prefix}.savings.acceptSavingsAccount\": functionDetails: functionId : \"be.kbc.savings.acceptSavingsAccount\", mode: \"create\" \"#{prefix}.savings.manageAccountInsurance\": functionDetails: functionId : \"be.kbc.savings.manageAccountInsurance\", mode: \"create\" \"#{prefix}.savings.manageAccountInsurance.delete\": functionDetails: functionId : \"be.kbc.savings.manageAccountInsurance\", mode: \"delete\" \"#{prefix}.savings.openSavingsAccount\": functionDetails: functionId : \"be.kbc.savings.openSavingsAccount\", mode: \"create\" \"#{prefix}.savings.settleSavingsAccount\": functionDetails: functionId : \"be.kbc.savings.settleSavingsAccount\", mode: \"create\" \"#{prefix}.payments.businessAccountRequest\": functionDetails: functionId : \"be.kbc.payments.businessAccountRequest\", mode: \"create\" \"#{prefix}.payments.cardPhoto\": functionDetails: functionId : \"be.kbc.payments.cardPhoto\", mode: \"create\" \"#{prefix}.payments.preaccountrequest\": functionDetails: functionId : \"be.kbc.payments.preAccountRequest\", mode: \"create\" \"#{prefix}.payments.privateAccountRequest\": functionDetails: functionId : \"be.kbc.payments.privateAccountRequest\", mode: \"create\" \"#{prefix}.payments.businessCreditCardRequest\": functionDetails: functionId : \"be.kbc.payments.businessCreditCardRequest\", mode: \"create\" \"#{prefix}.payments.preCardRequest\": functionDetails: functionId : \"be.kbc.payments.preCardRequest\", mode: \"create\" \"#{prefix}.payments.preCardRequest.createReplacement\": functionDetails: functionId : \"be.kbc.payments.preCardRequest\", mode: \"createReplacement\" \"#{prefix}.vehicle.dinoCarInsurance\": functionDetails: functionId : \"be.kbc.vehicle.dinoCarInsurance\", mode: \"create\" \"#{prefix}.vehicle.privateLease\": functionDetails: functionId : \"be.kbc.vehicle.privateLease\", mode: \"create\" \"#{prefix}.vehicle.privateLease.update\": functionDetails: functionId : \"be.kbc.vehicle.privateLease\", mode: \"update\" # Note: the deeplinks below are for local development testing only, the won't be available in the pillars # coffeelint: disable=no_backticks `//>>includeStart(\"local\", pragmas.local)` options[\"#{prefix}.credits.genericRequest\"] = functionDetails: functionId : \"be.kbc.credits.genericRequest\", mode: \"create\" options[\"#{prefix}.credits.genericRequest.continue\"] = functionDetails: functionId : \"be.kbc.credits.genericRequest\", mode: \"continue\" `//>>includeEnd(\"local\")` return options return launchOptions "; // 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/