Regular Expressions 101

Save & Share

  • Save new Regex
    ctrl+s
  • Update 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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

$re = '/(?<=Payment\/Retum I I\\\\r\\\\).{11}(?=\\\\r\\\\nPage)/m'; $str = '"El\\r\\nJERNST&YOUNC Expense Report\\r\\nI Date Prepared : 12—05—2020 I Business Unit : 1N1 1 1 Expense Report Number : 2173300892 I\\r\\nI Submitted : 20—05—2020 I Management Unit : 00167 I\\r\\nI GPN - Name I 1N010M48053 - Vinayak Aggarwal I Sub Management Unit : 0316068 I\\r\\nI Signature: I Approved By : I\\r\\nI Rank : Staff/Assistant—Grade 4 I Rank : I\\r\\nI Expense Details (AnaCh supporting reccipts) I I C = Chargeable P = Authorized I\\r\\n.otal Expense\\r\\nI L.p. IExpense Type I Date I Description I Location 1| Location 2 I I Type I Engagement I Activity |\\r\\n1 International Travel-Billable - 05-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,497.47 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 05/05/20\\r\\nDaily rental taxi expenses ~ CAD 79.70 CAD = INR\\r\\n4497.47\\r\\n2 International Travel-Billable - 06-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,542.61 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 06/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.50 CAD = INR\\r\\n4542.61\\r\\n3 International Travel-Billable - 07-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,532.81 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 07/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.17 CAD = INR\\r\\n4532.81\\r\\n4 International Travel-Billable - 08-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,536.97 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 08/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.40 CAD = INR\\r\\n4536.97\\r\\n5 International Travel-Billable - 1 1-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,547.59 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 11/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.46 CAD = INR\\r\\n4547.59\\r\\nI | | | I | I I I | I\\r\\nTotals (INR) I 206,455.77 I\\r\\nAdvance money/ prepayment I I\\r\\nPayment/Retum I I\\r\\n2173300892\\r\\nPage 1 of 3El\\r\\nJERNST&YOUNC Expense Report\\r\\nI Date Prepared : 12-05-2020 I Business Unit : 1N1 1 1 Expense Report Number : 2173300892 I\\r\\nI Submitted : 20—05—2020 I Management Unit : 00167 I\\r\\nI GPN - Name I IN010M48053 - Vinayak Aggarwal I Sub Management Unit : 0316068 I\\r\\nI Signature: I Approved By : I\\r\\nI Rank : Staff/Assistant—Grade 4 I Rank : I\\r\\nI Expense Details (AnaCh supporting reccipts) I‘otal ExpenseI C = Chargeable P = Authorized I\\r\\nI L.p. IExpense Type I Date I Description I Location 1| Location 2 I I Type I Engagement I Activity |\\r\\n6 International Travel-Billable - 12-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,545.99 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 12/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.46 CAD = INR\\r\\n4545.99\\r\\n7 International Travel-Billable - 12-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 78,268.47 P 39981687 0000 - General\\r\\nLodging _ Lodging Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 Canada -\\r\\nHotel accommodation: amex reimbursement\\r\\nVancouver - 5thMay-12thMay 2020~CAD 1390.06 =\\r\\nINR 78268.47\\r\\n8 International Travel-Billable - 13-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,573.91 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 13/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.94 CAD = INR\\r\\n4573.91\\r\\n9 International Travel-Billable - 14-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,528.05 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 14/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.10 CAD = INR\\r\\n4528.05\\r\\nTotals (INR) I 206,455.77 I\\r\\nAdvance money/ prepayment I I\\r\\n* * Payment/Retum I I\\r\\n| 2173300892 |\\r\\nPage 2 of 3El\\r\\nJERNST&YOUNC Expense Report\\r\\nI Date Prepared : 12-05-2020 I Business Unit : 1N1 1 1 Expense Report Number : 2173300892 I\\r\\nI Submitted : 20—05—2020 I Management Unit : 00167 I\\r\\nI GPN - Name I IN010M48053 - Vinayak Aggarwal I Sub Management Unit : 0316068 I\\r\\nI Signature: I Approved By : I\\r\\nI Rank : Staff/Assistant—Grade 4 I Rank : I\\r\\nI Expense Details (AnaCh supporting reccipts) I I C = Chargeable P = Authorized I\\r\\n.otal Expense\\r\\nI L.p. IExpense Type I Date I Description I Location 1| Location 2 I I Type I Engagement I Activity |\\r\\n10 International Travel-Billable - 15-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,563.58 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 15/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.70 CAD = INR\\r\\n4563.58\\r\\n1 1 International Travel-Billable - 18-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,488.32 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 18/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.12 CAD = INR\\r\\n4488.32\\r\\n12 International Travel-Billable - 19-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 78,327.10 P 39981687 0000 - General\\r\\nLodging _ Lodging Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 Canada -\\r\\nHotel accommodation: amex reimbursement\\r\\nVancouver - 12thMay-19thMay 2020\\r\\n~CAD 1390.06 = INR 78327.10\\r\\n13 International Travel-Billable - 19-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,502.90 P 39981687 0000 - General\\r\\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\\r\\nEngagement name : Agrium- Nutrien Project\\r\\nFoundation HLD Charge Code : 65411594 19/05/20\\r\\nDaily rental taxi expenses ~ CAD 80.28 CAD = INR\\r\\n4502.90\\r\\nTotals (INR) I 206,455.77 I\\r\\nAdvance money/ prepayment I I\\r\\n* * Payment/Retum I I\\r\\n| 2173300892 |\\r\\nPage 3 of 3Uber Tue, May 05, 2020 U ber Tue, May 05, 2020\\r\\n, . . , . .\\r\\nHere 5 your receipt for you r m p Here 5 your receipt for you r m p\\r\\nWe’re glad to have you as an Uber Rewards Gold member. We’re glad to have you as an Uber Rewards Gold member.\\r\\nTotal CA$39.48 Total CA$40.22\\r\\nTrip fare CA$29.89 Trip fare CA$30.58\\r\\nSubtotal CA$29.89 Subtotal CA$30.58\\r\\nGST CA$2.09 GST CA$2.14\\r\\nTolls, Surcharges, and Fees CA$7.50 Tolls, Surcharges, and Fees CA$7.50\\r\\nAmount Charged Amount Charged\\r\\n[351-4005 CA$39-48 Gimmes CA$40.22\\r\\nBASfljihegdpjago for more information, including invoices [Where available) liflmgdpjago for more information, including invoices (Where available)\\r\\nYou rode with Sean You rode with Adriel\\r\\nUberX 21.54 kilometres | 26 min(s) UberX 21.61 kilometres | 29 min(s)\\r\\nI 07:35 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada I 16:50 | 7430, Hopcott Rd. Delta, BC V4G 1B6, Canada\\r\\nI 08:01 | 7430, Hopcott Rd. Delta, BC V4G 1B6, Canada I 17:19 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada\\r\\nFare does not include fees that may be charged by your bank. Please contact your bank directly forinquiries. Fare does not include fees that may be charged by your bank. Please contact your bank directly for inquiries.Uber Wed, May 06, 2020 U ber Wed, May 06, 2020\\r\\n, . . , . .\\r\\nHere 5 your receipt for your trip Here 5 your receipt for your trip\\r\\nWe’re glad to have you as an Uber Rewards Gold member. We’re glad to have you as an Uber Rewards Gold member.\\r\\nTotal CA$39.66 Total CA$40.84\\r\\nTrip fare CA$30.06 Trip fare CA$31.16\\r\\nSubtotal CA$ 30.06 Subtotal CA$31.16\\r\\nGST CA$2.10 GST CA$2.18\\r\\nTolls, Surcharges, and Fees CA$7.50 Tolls, Surcharges, and Fees CA$7.50\\r\\nAmount Charged Amount Charged\\r\\n[EKMOOB CA$39.66 3:9,“2008 CA$40.84\\r\\nBASfljihegdpjago for more information, including invoices [Where available) liflmgdpjago for more information, including invoices (Where available)\\r\\nYou rode with Riley You rode with Archer\\r\\nUberX 21.64 kilometres | 26 min(s) UberX 21.60 kilometres | 27 min(s)\\r\\nI 07:30 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada I 17:01 | 7430, Hopcott Rd, Delta, BC V4G 1B6, Canada\\r\\nI 07:56 | 7430, Hopcott Rd. Delta, BC V4G 1B6, Canada I 17:28 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada\\r\\nFare does not include fees that may be charged by your bank. Please contact your bank directly forinquiries. Fare does not include fees that may be charged by your bank. Please contact your bank directly for inquiries.Uber Thu, May 07, 2020 U ber Thu, May 07, 2020\\r\\n, . . , . .\\r\\nHere 5 your receipt for your trip Here 5 your receipt for your trip\\r\\nWe’re glad to have you as an Uber Rewards Gold member. We’re glad to have you as an Uber Rewards Gold member.\\r\\nTotal CA$39.62 Total CA$40.55\\r\\nTrip fare CA$30.02 Trip fare CA$30.89\\r\\nSubtotal CA$ 30.02 Subtotal CA$30.89\\r\\nGST CA$2.10 GST CA$2.16\\r\\nTolls, Surcharges, and Fees CA$7.50 Tolls, Surcharges, and Fees CA$7.50\\r\\nAmount Charged Amount Charged\\r\\n[EKMOOB CA$39.62 3:9,“2008 CA$40.55\\r\\nBASfljihegdpjago for more information, including invoic…'; 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