Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • Update Regex
    ctrl+⇧+s
  • Save new 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
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

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "\\{((?!ToolTipML)[^\\{\\}])*\\}"; final String string = " { 66 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies the language to be used on printouts for this customer.;\n" + " ENG=Specifies the language to be used on printouts for this customer.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Language Code\";\n" + " Importance=Additional }\n\n" + " { 1000000087;3;Field ;\n" + " SourceExpr=\"Created By\";\n" + " Importance=Additional }\n\n" + " { 1000000090;3;Field ;\n" + " SourceExpr=\"Creation Date\";\n" + " Importance=Additional }\n\n" + " { 1000000007;3;Field ;\n" + " CaptionML=[ENU=Bill-To Alert;\n" + " ENG=Bill-To Alert];\n" + " ToolTipML=[ENU=Illuminates when invoices are paid by another customer (the Bill-to).;\n" + " ENG=Illuminates when invoices are paid by another customer (the Bill-to).];\n" + " SourceExpr=BillToText;\n" + " Editable=FALSE;\n" + " Style=Unfavorable;\n" + " StyleExpr=TRUE }\n\n" + " { 1000000011;3;Field ;\n" + " ToolTipML=[ENU=Default Contact for the Accounts Department, selected from the Contact List.;\n" + " ENG=Default Contact for the Accounts Department, selected from the Contact List.];\n" + " SourceExpr=\"Accounts Contact No.\" }\n\n" + " { 1000000010;3;Field ;\n" + " ToolTipML=[ENU=Specifies the accounts contact name for the customer.;\n" + " ENG=Specifies the accounts contact name for the customer.];\n" + " SourceExpr=\"Accounts Contact Name\" }\n\n" + " { 1000000009;3;Field ;\n" + " ToolTipML=[ENU=Specifies the customer's alternate telephone number. Synchronized with the Contact Card.;\n" + " ENG=Specifies the customer's alternate telephone number. Synchronized with the Contact Card.];\n" + " SourceExpr=\"Phone 2\";\n" + " Importance=Additional }\n\n" + " { 1000000008;3;Field ;\n" + " ToolTipML=[ENU=Specifies the customer's alternate fax number. Synchronized with the Contact Card.;\n" + " ENG=Specifies the customer's alternate fax number. Synchronized with the Contact Card.];\n" + " SourceExpr=\"Fax 2\";\n" + " Importance=Additional }\n\n" + " { 1905885101;1;Group ;\n" + " CaptionML=[ENU=Invoicing;\n" + " ENG=Invoicing] }\n\n" + " { 34 ;2 ;Field ;\n" + " CaptionML=[ENU=Bill-to Customer;\n" + " ENG=Bill-to Customer];\n" + " ToolTipML=[ENU=Specifies a different customer who will be invoiced for products that you sell to the customer in the Name field on the customer card.;\n" + " ENG=Specifies a different customer who will be invoiced for products that you sell to the customer in the Name field on the customer card.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Bill-to Customer No.\";\n" + " Importance=Additional }\n\n" + " { 1000000041;2;Field ;\n" + " CaptionML=[ENU=Bill-to Customer Name;\n" + " ENG=Bill-to Customer Name];\n" + " SourceExpr=BillToName;\n" + " Importance=Promoted;\n" + " Editable=FALSE }\n\n" + " { 29 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies the customer's VAT registration number for customers in EU countries/regions.;\n" + " ENG=Specifies the customer's VAT registration number for customers in EU countries/regions.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"VAT Registration No.\";\n" + " OnDrillDown=VAR\n" + " VATRegistrationLogMgt@1000 : Codeunit 249;\n" + " BEGIN\n" + " VATRegistrationLogMgt.AssistEditCustomerVATReg(Rec);\n" + " END;\n" + " }\n\n" + " { 61 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies the customer in connection with electronic document sending.;\n" + " ENG=Specifies the customer in connection with electronic document sending.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=GLN;\n" + " Importance=Additional }\n\n" + " { 156 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies which customer address is inserted on sales quotes that you create for the customer.;\n" + " ENG=Specifies which customer address is inserted on sales quotes that you create for the customer.];\n" + " ApplicationArea=#Advanced;\n" + " SourceExpr=\"Copy Sell-to Addr. to Qte From\";\n" + " Importance=Additional }\n\n" + " { 1000000095;2;Field ;\n" + " ToolTipML=[ENU=The INCO trading terms used by the customer.;\n" + " ENG=The INCO trading terms used by the customer.];\n" + " SourceExpr=\"Incoterms Code\" }\n\n" + " { 36 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies how many copies of an invoice for the customer will be printed at a time.;\n" + " ENG=Specifies how many copies of an invoice for the customer will be printed at a time.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Invoice Copies\";\n" + " Importance=Additional }\n\n" + " { 170 ;2 ;Group ;\n" + " Name=PostingDetails;\n" + " CaptionML=[ENU=Posting Details;\n" + " ENG=Posting Details];\n" + " GroupType=Group }\n\n" + " { 70 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies the customer's trade type to link transactions made for this customer with the appropriate general ledger account according to the general posting setup.;\n" + " ENG=Specifies the customer's trade type to link transactions made for this customer with the appropriate general ledger account according to the general posting setup.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Gen. Bus. Posting Group\";\n" + " Importance=Promoted;\n" + " ShowMandatory=TRUE }\n\n" + " { 58 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies the customer's VAT specification to link transactions made for this customer to.;\n" + " ENG=Specifies the customer's VAT specification to link transactions made for this customer to.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"VAT Bus. Posting Group\";\n" + " Importance=Additional }\n\n" + " { 38 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies the customer's market type to link business transactions to.;\n" + " ENG=Specifies the customer's market type to link business transactions to.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Customer Posting Group\";\n" + " Importance=Promoted;\n" + " ShowMandatory=TRUE }\n\n" + " { 68 ;2 ;Group ;\n" + " Name=PricesandDiscounts;\n" + " CaptionML=[ENU=Prices and Discounts;\n" + " ENG=Prices and Discounts];\n" + " GroupType=Group }\n\n" + " { 1000000015;3;Field ;\n" + " ToolTipML=[ENU=Specifies whether the customer is a member of a Buying Group.;\n" + " ENG=Specifies whether the customer is a member of a Buying Group.];\n" + " SourceExpr=\"Buying Group Code\" }\n\n" + " { 40 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies the customer price group code, which you can use to set up special sales prices in the Sales Prices window.;\n" + " ENG=Specifies the customer price group code, which you can use to set up special sales prices in the Sales Prices window.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Customer Price Group\";\n" + " Importance=Promoted }\n\n" + " { 44 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies the customer discount group code, which you can use as a criterion to set up special discounts in the Sales Line Discounts window.;\n" + " ENG=Specifies the customer discount group code, which you can use as a criterion to set up special discounts in the Sales Line Discounts window.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Customer Disc. Group\";\n" + " Importance=Promoted }\n\n" + " { 46 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies if a sales line discount is calculated when a special sales price is offered according to setup in the Sales Prices window.;\n" + " ENG=Specifies if a sales line discount is calculated when a special sales price is offered according to setup in the Sales Prices window.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Allow Line Disc.\";\n" + " Importance=Additional }\n\n" + " { 1000000016;3;Field ;\n" + " ToolTipML=[ENU=Allows Break Quantity discounts for an Assortment (or Basket) of Items. If a Total Quantity of a defined Item Discount Group is purchased then a Discount applies.;\n" + " ENG=Allows Break Quantity discounts for an Assortment (or Basket) of Items. If a Total Quantity of a defined Item Discount Group is purchased then a Discount applies.];\n" + " SourceExpr=\"Allow Assorted Discount\" }\n\n" + " { 42 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies a code for the invoice discount terms that you have defined for the customer.;\n" + " ENG=Specifies a code for the invoice discount terms that you have defined for the customer.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " NotBlank=Yes;\n" + " SourceExpr=\"Invoice Disc. Code\";\n" + " Importance=Additional }\n\n" + " { 129 ;3 ;Field ;\n" + " ToolTipML=[ENU=Specifies if the Unit Price and Line Amount fields on document lines should be shown with or without VAT.;\n" + " ENG=Specifies if the Unit Price and Line Amount fields on document lines should be shown with or without VAT.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Prices Including VAT\";\n" + " Importance=Additional }\n\n" + " { 1901677601;1;Group ;\n" + " CaptionML=[ENU=Payments;\n" + " ENG=Payments] }\n\n" + " { 160 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies a prepayment percentage that applies to all orders for this customer, regardless of the items or services on the order lines.;\n" + " ENG=Specifies a prepayment percentage that applies to all orders for this customer, regardless of the items or services on the order lines.];\n" + " ApplicationArea=#Prepayments;\n" + " SourceExpr=\"Prepayment %\";\n" + " Importance=Additional }\n\n" + " { 48 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies how to apply payments to entries for this customer.;\n" + " ENG=Specifies how to apply payments to entries for this customer.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Application Method\";\n" + " Importance=Additional }\n\n" + " { 21 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies for direct debit collections if the customer that the payment is collected from is a person or a company.;\n" + " ENG=Specifies for direct debit collections if the customer that the payment is collected from is a person or a company.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Partner Type\";\n" + " Importance=Additional }\n\n" + " { 50 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies a code that indicates the payment terms that you require of the customer.;\n" + " ENG=Specifies a code that indicates the payment terms that you require of the customer.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Payment Terms Code\";\n" + " Importance=Promoted;\n" + " ShowMandatory=TRUE }\n\n" + " { 1000000018;2;Field ;\n" + " ToolTipML=[ENU=Date Formula. Overrides default Grace Period Calculation. Populated from Payment Terms.;\n" + " ENG=Date Formula. Overrides default Grace Period Calculation. Populated from Payment Terms.];\n" + " SourceExpr=\"Grace Period Calculation\" }\n\n" + " { 11 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies how the customer usually submits payment, such as bank transfer or check.;\n" + " ENG=Specifies how the customer usually submits payment, such as bank transfer or cheque.];\n" + " ApplicationArea=#Basic,#Suite;\n" + " SourceExpr=\"Payment Method Code\";\n" + " Importance=Additional }\n\n" + " { 15 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies how reminders about late payments are handled for this customer.;\n" + " ENG=Specifies how reminders about late payments are handled for this customer.];\n" + " ApplicationArea=#Advanced;\n" + " SourceExpr=\"Reminder Terms Code\";\n" + " Importance=Additional }\n\n" + " { 52 ;2 ;Field ;\n" + " ToolTipML=[ENU=Specifies finance charges are calculated for the customer.;\n" + " ENG=Specifies finance charges are calculated for the customer.];\n" + " ApplicationArea=#Advanced;\n" + " SourceExpr=\"Fin. Charge Terms Code\";"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html