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

/
/
gm

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)[0-9]{2}[-|\/]{1}[0-9]{2}[-|\/]{1}[0-9]{4}" Local $sString = "03-Feb-2021" & @CRLF & _ "Mr./Ms. JOHN THACHIL" & @CRLF & _ "MADHURA SURAKSHA APARTMENT" & @CRLF & _ "S6 2ND FLOOR" & @CRLF & _ "JP NAGAR 5TH PHASE" & @CRLF & _ "BANGALORE 560078" & @CRLF & _ "Dear Customer, " & @CRLF & _ "Subject: EasyEMI on your HDFC Bank Credit Card Number:552260XXXXXX0961" & @CRLF & _ "We are pleased to grant you the EasyEMI payment facility as per the details stated below. The" & @CRLF & _ "transaction amount has been converted into EasyEMI as per your request" & @CRLF & _ "EasyEMI Loan no. 0000000000065214714" & @CRLF & _ "Unsecured Loan Type EasyEMI" & @CRLF & _ "Amount Rs.3399.00" & @CRLF & _ "Tenure 3 Months" & @CRLF & _ "EasyEMI Fixed Finance Charges on Reducing Balance 1.25% p.m." & @CRLF & _ "EMI Amount Rs.1161.44(Excluding GST)*" & @CRLF & _ "Merchant Name " & @CRLF & _ "Processing Fee Rs.199.00" & @CRLF & _ "*GST at 18% will be charged on the following and are subjected to change as per Govt.Announcement:" & @CRLF & _ "1.EasyEMI Finance Charges Component on the EMI amount on a monthly basis" & @CRLF & _ "2.Processing fee, if any" & @CRLF & _ "3.Pre-closure charges, if any" & @CRLF & _ "Please refer to the enclosed amortization schedule for EMI details" & @CRLF & _ "For the first EMI, the interest will be calculated from the loan booking date till the payment due date. This" & @CRLF & _ "is effective only for loans booked from Feb 2019 onwards.In case you require any further assistance , pls" & @CRLF & _ "contact Phone Banking within 7 days of receiving this letter" & @CRLF & _ "EasyEMI transactions are not eligible for Reward Points.This EasyEMI can be pre-closed anytime during the" & @CRLF & _ "tenure. In case of pre-closure of the EasyEMI facility, there will be no Penalty levied currently. As the pre-closure" & @CRLF & _ "charge is subjected to change, we request you to get in touch with your nearest call centre for the applicable" & @CRLF & _ "charge, if any, if you decide to pre-close the EasyEMI. Partial pre-payment or partial closure is not permitted on" & @CRLF & _ "this loan" & @CRLF & _ "Additional Finance Charges if any on the principal outstanding from last statement date till date of loan pre-" & @CRLF & _ "closure need to be paid by customer." & @CRLF & _ "Please also note that the above mentioned EMI amounts will be included to your monthly HDFC Bank Credit Card" & @CRLF & _ "statements and will be payable as part of the Minimum Amount Due." & @CRLF & _ "If your HDFC Bank Card gets closed before all the installments have been charged, the loan outstanding will get" & @CRLF & _ "debited to your card account and you’re expected to pay the amount in full. In case of default in payment of credit" & @CRLF & _ "card dues or EMIs by the due dates, your card account is liable to be suspended and could further be terminated." & @CRLF & _ "The terms and conditions contained in the Cardmember Agreement apply over and above the terms and" & @CRLF & _ "conditions for this loan. In case you do not agree to any of the details above, or require any further assistance," & @CRLF & _ "please contact the nearest customer service call centre at the numbers provided below, within 7 days of receiving" & @CRLF & _ "this letter." & @CRLF & _ "Enclosed Amortization schedule of Loan Number 0000000000065214714 for Loan Amount Rs.3399.00" & @CRLF & _ "(*GST extra @18% on Interest Component)" & @CRLF & _ "NoNo" & @CRLF & _ "EasyEMIEasyEMI" & @CRLF & _ "StatementPrincipalEMIBalanceStatementPrincipalEMIBalance" & @CRLF & _ "FinanceFinance" & @CRLF & _ "DateAmountAmountDateAmountAmount" & @CRLF & _ "ChargesCharges" & @CRLF & _ "onon" & @CRLF & _ "ReducingReducing" & @CRLF & _ "BalanceBalance" & @CRLF & _ "21-02-202121-04-2021" & @CRLF & _ "11118.9670.881189.842280.0431147.1014.331161.430.00" & @CRLF & _ "21-03-2021" & @CRLF & _ "21132.9428.501161.441147.10" & @CRLF & _ "This is a computer generated letter and does not require a signature." Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm