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

/
/
g

Test String

Code Generator

Generated Code

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

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php