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)(\d{2,4})-?(\w{3}|\d{2})-(\d{2,4})" Local $sString = "Dear Customer, SBI MUTUAL FUND ISIP bill of Rs. 5000 has been presented at !ClClBank.com. It would be debited through autodebit on due date 20-Nov-19" & @CRLF & _ "ALERT:You've spent Rs.1936.00 via Debit Card xx2127 at OM SAI MEDICINERS on 2020-01-03:13:02:10.AvI Bal Rs.66697.85.Not you?Call 18002586161" & @CRLF & _ "AvbI Bal in your A/C. No.XXXXXXXXXXX31 34 on EOD 30DEC-2019 is INR 34,072.58, Tot. avbl bal (including linked deposits and Limit) is INR 34,072.58" & @CRLF & _ "NEFT Transaction with reference number 21854417971DC for Rs. 8600.00 has been credited to the beneficiary account on 04-01-2020 at 09:35:46" & @CRLF & _ "Your A/c XXXXXXXXXXXX103 in Pune-Deccan Gymkhana credited INR 3326.00 on 03-01-2020 by TRF. AvI Bal is +20094.13" & @CRLF & _ "Ur transaction on HDFC Bank DEBIT/ATM Card ending 2127 for Rs. 860.00 has been credited/reversed by DUTTA BHANDAR on 2020-01-02:14:12:23" & @CRLF & _ "Dear Customer, SBI MUTUAL FUND ISIP bill of Rs. 5000 has been presented at !ClCiBank.com. It would be debited through autodebit on due date 20-Nov-19" & @CRLF & _ "Your A/c XXXXXXXXXXXX103 in Pune-Deccan Gymkhana debited INR 2000.00 on 24-12-2019 by TRF. AvI Bal is +5583.13" & @CRLF & _ "Acct XX852 debited with INR 4,499.00 on 02-Dec-19 & Acct XX248 credited. IMPS: 933612258069. Call 18002662 for dispute or SMS BLOCK 852 to 9215676766" & @CRLF & _ "ALERT:You've spent Rs.860.00 via Debit Card xx2127 at DUTTA BHANDAR on 2020-01-02:14:15:34.AvI Bal Rs.68633.85.Not you?Call 18002586161" & @CRLF & _ "Txn of INR 301.86 done on Acct XX278 on 27-Nov-19.Info: IIN*Zomato .Avbl Bal:INR 6,14,402.34.Call 18002662 for pute or SMS BLOCK 278 to" & @CRLF & _ " ‘Txn of INR 1,477.00 done on Acct XX340 on 03-Jan-20.Info: IPS*Oak groov.Avbl Bal:INR 24,296.14.Call 18002662 for dispute or SMS BLOCK 340 to 9215676766" & @CRLF & _ " Txn of INR 130.00 done on Acct XX278 on 25-Nov-19.Info: IIN*Zomato .Avbl Bal:INR 6,14,855.76.Call 18002662 for dispute or SMS BLOCK 278 to 9215676766" & @CRLF & _ "ALERT:You've spent Rs.1000.00 via Debit Card xx2127 at OM SAI MEDICINERS on 2020-01-03:13:02:40.AvI Bal Rs.65697.85.Not you?Call 18002586161" & @CRLF & _ "ALERT: You've spent Rs.110370.00 on CREDIT Card xx8248 at KEJALS FURNISHINGS on 2020-01-04:15:13:21. AvI bal - Rs. 213979.00, curr o/s Rs.150021.00.Not you? Call 18002586161" & @CRLF & _ "Acct XX340 debited with INR 4,622.83 on 01-Jan-20.Info: BIL*001884473.AvbI Bal:INR 25,773.14.Call 18002662 for dispute or SMS BLOCK 340 to 9215676766" & @CRLF & _ "Ur transaction on HDFC Bank CREDIT Card ending 8248 for Rs. 2.00 has been credited/reversed by AMAZON on 2020-01-06:05:25:42" & @CRLF & _ "Dear Customer, Payment of INR 4622.83 has been received on your ICICI Bank Credit Card Account 4xxx5004 on 01-JAN-20.Thank you" & @CRLF & _ "Your Ac XX2148 is debited with INR10,000.00 NFS*CASH WDL*30-12-15. Avbl Bal INR1,87,552.27 To bank on phone with iMobile, click mobile.icicibank.com/dl" & @CRLF & _ "Txn of INR 141.00 done on Acct XX340 on 31-Dec-19. Info: IIN*Amazon_ .AvbI Bal:INR 30,255.97.Call 18002662 for dispute or SMS BLOCK 340 to 9215676766" & @CRLF & _ "INR219.00 debited on Credit Card XX4005 on 26Nov-19.Info:APPLE.COM BILL.AvbI Lmt:INR8,643.51.Call 18002662 for dispute or SMS. BLOCK 4005 to 9215676766" & @CRLF & _ "Your a/c no. XXXXXXXX4876 is debited for Rs. 2000.00 on 02-01-20 and a/c XXXXXXX017 credited (IMPS Ref no 000216702189). Download YONO @ www.yonosbi.com" & @CRLF & _ "ALERT: You've spent Rs.1000.00 on CREDIT Card xx8248 at AMAZON on 2020-01-05:22:54:14 -AvI bal - Rs. 208004.00, curr o/s Rs.155996.00.Not you? Call 18002586161" & @CRLF & _ "Dear Customer, payment of Rs. 5000 towards SBI MUTUAL FUND ISIP is scheduled on 20-Nov-19. Pls maintain sufficient balance in Acct XX2148" & @CRLF & _ "ALERT: You've spent Rs.3100.00 on CREDIT Card xx8248 at D.J.PETROLEUM on 2019-11-29:12:35:16. AvI bal - Rs. 271584.00, curr o/s Rs.8416.00.Not you? Call 18002586161" & @CRLF & _ "Dear Customer, bill of Rs. 738 towards BSNL CELL ONE PUNE is due on 21-Nov-19. To make a payment, click https://icici.in/ PR5PO7k or login to Internet Banking/ iMobile" & @CRLF & _ "Dear Customer, Your a/c no. XXXXXXXX4435 is credited by Rs. 74,739.00 on 09Aug-2018 00:45:17 by a/c linked to mobile XXXXXO0O0000. (IMPS Ref no 822100339658)." & @CRLF & _ "" & @CRLF & _ "" 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