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

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