Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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

/
/
g

Test String

Code Generator

Generated Code

$re = '/\<listRel:entityId\>(\d+)[\s\w]+<\/listRel:entityId\>/'; $str = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2016_1.platform.webservices.netsuite.com"> <platformMsgs:nsId>WEBSERVICES_4485702_0725201720695377301235376538_1740c596260</platformMsgs:nsId> </platformMsgs:documentInfo> </soapenv:Header> <soapenv:Body> <searchResponse xmlns="urn:messages_2016_1.platform.webservices.netsuite.com"> <platformCore:searchResult xmlns:platformCore="urn:core_2016_1.platform.webservices.netsuite.com"> <platformCore:status isSuccess="true"/> <platformCore:totalRecords>1</platformCore:totalRecords> <platformCore:pageSize>1000</platformCore:pageSize> <platformCore:totalPages>1</platformCore:totalPages> <platformCore:pageIndex>1</platformCore:pageIndex> <platformCore:searchId>WEBSERVICES_4485702_0725201720695377301235376538_1740c596260</platformCore:searchId> <platformCore:recordList> <platformCore:record internalId="13094669" xsi:type="listRel:Customer" xmlns:listRel="urn:relationships_2016_1.lists.webservices.netsuite.com"> <listRel:entityId>917857 James Bond</listRel:entityId> <listRel:isPerson>true</listRel:isPerson> <listRel:firstName>James</listRel:firstName> <listRel:lastName>Bond</listRel:lastName> <listRel:companyName>Anonymous Customer (Sales Inbox)</listRel:companyName> <listRel:entityStatus internalId="13"> <platformCore:name>CUSTOMER-Closed Won</platformCore:name> </listRel:entityStatus> <listRel:parent internalId="4453"> <platformCore:name>2 Anonymous Customer (Sales Inbox)</platformCore:name> </listRel:parent> <listRel:phone>(925) 206-3542</listRel:phone> <listRel:email>jb@mi6.com</listRel:email> <listRel:isInactive>false</listRel:isInactive> <listRel:category internalId="6"> <platformCore:name>Other (.com)</platformCore:name> </listRel:category> <listRel:language>_usEnglish</listRel:language> <listRel:dateCreated>2017-07-17T15:13:48.000-07:00</listRel:dateCreated> <listRel:emailPreference>_default</listRel:emailPreference> <listRel:creditHoldOverride>_auto</listRel:creditHoldOverride> <listRel:unbilledOrders>0.0</listRel:unbilledOrders> <listRel:consolUnbilledOrders>0.0</listRel:consolUnbilledOrders> <listRel:consolOverdueBalance>0.0</listRel:consolOverdueBalance> <listRel:consolDepositBalance>0.0</listRel:consolDepositBalance> <listRel:consolBalance>0.0</listRel:consolBalance> <listRel:consolAging>0.0</listRel:consolAging> <listRel:consolAging1>0.0</listRel:consolAging1> <listRel:consolAging2>0.0</listRel:consolAging2> <listRel:consolAging3>0.0</listRel:consolAging3> <listRel:consolAging4>0.0</listRel:consolAging4> <listRel:currency internalId="1"> <platformCore:name>US Dollars</platformCore:name> </listRel:currency> <listRel:shipComplete>false</listRel:shipComplete> <listRel:taxable>true</listRel:taxable> <listRel:taxItem internalId="1178"> <platformCore:name>AVATAX</platformCore:name> </listRel:taxItem> <listRel:aging>0.0</listRel:aging> <listRel:aging1>0.0</listRel:aging1> <listRel:aging2>0.0</listRel:aging2> <listRel:aging3>0.0</listRel:aging3> <listRel:aging4>0.0</listRel:aging4> <listRel:giveAccess>false</listRel:giveAccess> <listRel:accessRole internalId="14"> <platformCore:name>Customer Center</platformCore:name> </listRel:accessRole> <listRel:receivablesAccount internalId="-10"> <platformCore:name>Use System Preference</platformCore:name> </listRel:receivablesAccount> <listRel:lastModifiedDate>2017-07-25T09:07:54.000-07:00</listRel:lastModifiedDate> <listRel:stage>_customer</listRel:stage> <listRel:emailTransactions>false</listRel:emailTransactions> <listRel:printTransactions>false</listRel:printTransactions> <listRel:faxTransactions>false</listRel:faxTransactions> <listRel:isBudgetApproved>false</listRel:isBudgetApproved> <listRel:globalSubscriptionStatus>_softOptIn</listRel:globalSubscriptionStatus> <listRel:customFieldList> <platformCore:customField internalId="3153" scriptId="custentity_cseg_v_subsidiary" xsi:type="platformCore:SelectCustomFieldRef"> <platformCore:value internalId="1" typeId="448"> <platformCore:name>North America</platformCore:name> </platformCore:value> </platformCore:customField> <platformCore:customField internalId="6" scriptId="custentity_esc_last_modified_date" xsi:type="platformCore:DateCustomFieldRef"> <platformCore:value>2017-07-24T22:00:00.000-07:00</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2416" scriptId="custentity_muv_synctomarketo" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="1498" scriptId="custentity_pri_line_item_modifier_entity" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2269" scriptId="custentity_remove_from_campaign" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="3125" scriptId="custentity_v_auto_created_web_company" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="3027" scriptId="custentity_v_companygroup" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="3157" scriptId="custentity_v_cust_require_po" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="1149" scriptId="custentity_v_demo_customer" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2266" scriptId="custentity_v_do_not_call" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="601" scriptId="custentity_v_do_not_sync_w_parent" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2885" scriptId="custentity_v_fromopportunity" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="3141" scriptId="custentity_v_group_domains" xsi:type="platformCore:StringCustomFieldRef"> <platformCore:value>ERROR: Invalid Expression</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2867" scriptId="custentity_v_hot_activity_marketo" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="3214" scriptId="custentity_v_last_sent_to_marketo" xsi:type="platformCore:DateCustomFieldRef"> <platformCore:value>2017-07-17T15:14:00.000-07:00</platformCore:value> </platformCore:customField> <platformCore:customField internalId="1671" scriptId="custentity_v_locale" xsi:type="platformCore:SelectCustomFieldRef"> <platformCore:value internalId="13" typeId="299"> <platformCore:name>English - Canada</platformCore:name> </platformCore:value> </platformCore:customField> <platformCore:customField internalId="3257" scriptId="custentity_v_marketo_no_sync" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="3215" scriptId="custentity_v_marketo_send_status" xsi:type="platformCore:StringCustomFieldRef"> <platformCore:value>created</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2248" scriptId="custentity_v_netsuite_1_campaigns" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="3144" scriptId="custentity_v_omit_statements" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2264" scriptId="custentity_v_payment_notification" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="600" scriptId="custentity_v_region_class" xsi:type="platformCore:SelectCustomFieldRef"> <platformCore:value internalId="8" typeId="-101"> <platformCore:name>North America : US</platformCore:name> </platformCore:value> </platformCore:customField> <platformCore:customField internalId="1668" scriptId="custentity_v_require_invoice_submission" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2874" scriptId="custentity_v_teamgroup" xsi:type="platformCore:SelectCustomFieldRef"> <platformCore:value internalId="9" typeId="410"> <platformCore:name>Sales Group (US)</platformCore:name> </platformCore:value> </platformCore:customField> <platformCore:customField internalId="2267" scriptId="custentity_v_unsubscribe_mktg_email" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2957" scriptId="custentity_v_usemailmerge" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> <platformCore:customField internalId="2855" scriptId="custentity_v_vat_exempt" xsi:type="platformCore:BooleanCustomFieldRef"> <platformCore:value>false</platformCore:value> </platformCore:customField> </listRel:customFieldList> </platformCore:record> </platformCore:recordList> </platformCore:searchResult> </searchResponse> </soapenv:Body> </soapenv:Envelope>'; 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