Regular Expressions 101

Save & Share

  • Regex Version: ver. 9
  • 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
No Match

/
/
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 = "^--.*--$|=|('|").*?\1|[^\t\n\f \/>"'=]+" Local $sString = "[2021-11-24 16:26:27,931] [dc4-10.123.66.197-http-bio-8080-exec-1500_LADC_72E18BC06AF39AA1FCC7A95DF068E068] [INFO] [LoggingInInterceptor] [] [Inbound Message" & @CRLF & _ "----------------------------" & @CRLF & _ "ID: 5520137" & @CRLF & _ "Response-Code: 200" & @CRLF & _ "Encoding: UTF-8" & @CRLF & _ "Content-Type: text/xml;charset=utf-8" & @CRLF & _ "Headers: {connection=[keep-alive], Content-Length=[3351], Content-Security-Policy=[default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';], content-type=[text/xml;charset=utf-8], Date=[Wed, 24 Nov 2021 16:26:27 GMT], Keep-Alive=[timeout=30], Referrer-Policy=[origin-when-cross-origin], Server=[SWS], SOAPAction=[""], Strict-Transport-Security=[max-age=31536000], X-Content-Type-Options=[nosniff], X-Frame-Options=[SAMEORIGIN], X-XSS-Protection=[1; mode=block]}" & @CRLF & _ "Payload: <?xml version="1.0" encoding="UTF-8"?>" & @CRLF & _ "<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header><eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" eb:version="1.0" soap-env:mustUnderstand="1"><eb:From><eb:PartyId eb:type="URI">123123</eb:PartyId></eb:From><eb:To><eb:PartyId eb:type="URI">99999</eb:PartyId></eb:To><eb:CPAId>LA</eb:CPAId><eb:ConversationId>LADC_72E18BC06AF39AA1FCC7A95DF068E068</eb:ConversationId><eb:Service>SabreCommand</eb:Service><eb:Action>SabreCommandLLSRS</eb:Action><eb:MessageData><eb:MessageId>2651654591878281621</eb:MessageId><eb:Timestamp>2021-11-24T16:26:27</eb:Timestamp><eb:RefToMessageId>mid:2021-11-24T16:26:27@sabre.com</eb:RefToMessageId></eb:MessageData></eb:MessageHeader><wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"><wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/RESE!ICESMSLB\/RES.LB!XXXXXXXXX9844!1410!261</wsse:BinarySecurityToken></wsse:Security></soap-env:Header><soap-env:Body><SabreCommandLLSRS xmlns="http://webservices.sabre.com/sabreXML/2003/07" EchoToken="String" TimeStamp="2021-11-24T16:26:27" Target="Production" Version="2003A.TsabreXML1.6.1" SequenceNmbr="1" PrimaryLangID="en-us" AltLangID="en-us">" & @CRLF & _ " <Response><![CDATA[CZMWQP]]><![CDATA[" & @CRLF & _ " 1.1SEREY/ANTOINE]]><![CDATA[" & @CRLF & _ " 1 AF1318V 24DEC F CDGFRA HK1 1525 1645 /RLAF*3AL3UX /E]]><![CDATA[" & @CRLF & _ " /OPERATED BY HOP]]><![CDATA[" & @CRLF & _ " 2 LA8071L 24DEC F FRAGRU HK1 2015 0420 25DEC J /E]]><![CDATA[" & @CRLF & _ " /OPERATED BY LATAM AIRLINES BRASIL]]><![CDATA[" & @CRLF & _ " 3 LA4777L 25DEC J GRUCWB HK1 0820 0925 /E]]><![CDATA[" & @CRLF & _ " /OPERATED BY LATAM AIRLINES BRASIL]]><![CDATA[" & @CRLF & _ "TKT/TIME LIMIT]]><![CDATA[" & @CRLF & _ " 1.T-28OCT-UHN5SHT]]><![CDATA[" & @CRLF & _ " 2.TE 0452159694657 SEREY/A UHN5SHT 1448/28OCT]]><![CDATA[" & @CRLF & _ "VCR COUPON DATA EXISTS *VI TO DISPLAY]]><![CDATA[" & @CRLF & _ "PHONES]]><![CDATA[" & @CRLF & _ " 1.HDQ33-33-762493204-M]]><![CDATA[" & @CRLF & _ "PASSENGER EMAIL DATA EXISTS *PE TO DISPLAY ALL]]><![CDATA[" & @CRLF & _ "PRICE QUOTE RECORD EXISTS - *PQS]]><![CDATA[" & @CRLF & _ "LA FACTS]]><![CDATA[" & @CRLF & _ " 1.SSR FOID LA HK1/PPFR15DC33906]]><![CDATA[" & @CRLF & _ " 2.OSI VENTA WWW.LAN.COM]]><![CDATA[" & @CRLF & _ " 3.SSR ADTK LA TO AF BY 31OCT 1200 HDQ OTHERWISE WILL BE XLD]]><![CDATA[" & @CRLF & _ " 4.SSR LAXP LA 8071L24DEC/LATAM XP USER NN1 ]]><![CDATA[" & @CRLF & _ " 6.SSR BRND LA 8071L24DEC/SL ]]><![CDATA[" & @CRLF & _ " 7.SSR LAXP LA 4777L25DEC/LATAM XP USER NN1 ]]><![CDATA[" & @CRLF & _ " 9.SSR BRND LA 4777L25DEC/SL ]]><![CDATA[" & @CRLF & _ "GENERAL FACTS]]><![CDATA[" & @CRLF & _ " 1.SSR FOID AF HK1/PPFR15DC33906]]><![CDATA[" & @CRLF & _ " 2.OSI YY VENTA WWW.LAN.COM]]><![CDATA[" & @CRLF & _ " 3.SSR OTHS AF LAXP]]><![CDATA[" & @CRLF & _ " 4.SSR OTHS AF LAXP]]><![CDATA[" & @CRLF & _ " 6.SSR OTHS AF LAXP]]><![CDATA[" & @CRLF & _ " 7.OSI LA SC.REAC 0228/31OCT21]]><![CDATA[" & @CRLF & _ " 8.SSR OTHS AF LAXP]]><![CDATA[" & @CRLF & _ " 9.SSR OTHS AF LAXP]]><![CDATA[" & @CRLF & _ "REMARKS]]><![CDATA[" & @CRLF & _ " 1.H-ID VENTA WWW.1646474003]]><![CDATA[" & @CRLF & _ " 2.H-LANCOM PAYMENT ATTEMPT]]><![CDATA[" & @CRLF & _ " 4.H-PLS CHK POSS DUPE OR LAN WILL CNL AFTER 12 HRS]]><![CDATA[" & @CRLF & _ " 5.H-PLS ADV TKT NBR BEFORE 31OCT21 1256 UHN LT OR AUTO CNL]]><![CDATA[" & @CRLF & _ " 6.H-SERVICE FEE EUR0.00/P1]]><![CDATA[" & @CRLF & _ " 7.H-IDVENTAPAGO WWW.1646474983]]><![CDATA[" & @CRLF & _ " 8.PNR WORKED ARU]]><![CDATA[" & @CRLF & _ " 9.NO ACTIONABLE TICKETS]]><![CDATA[" & @CRLF & _ " 10.NO ACTIONABLE TICKETS]]><![CDATA[" & @CRLF & _ "OAC - LA UHN LW 2049849 ]]><![CDATA[" & @CRLF & _ "UHN-UHN-LW.UHN5SHT 0656/28OCT21 CZMWQP H]]></Response>" & @CRLF & _ "</SabreCommandLLSRS></soap-env:Body></soap-env: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