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

/
/
gm

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 = "(?m)(\bPublic Class AddressVerification\b)|(\bEnd Class\b)" Local $sString = "" & @CRLF & _ "Public Class AddressVerification" & @CRLF & _ " Public SingleAddress As Boolean" & @CRLF & _ " Public Address As Address" & @CRLF & _ " Public Addresses As List(Of Address)" & @CRLF & _ "" & @CRLF & _ " Public Sub New(Optional singleAddress As Boolean = False)" & @CRLF & _ " Me.SingleAddress = singleAddress" & @CRLF & _ "" & @CRLF & _ " If Not singleAddress Then" & @CRLF & _ " Addresses = New List(Of Address)()" & @CRLF & _ " Else" & @CRLF & _ " Address = New Address()" & @CRLF & _ " End If" & @CRLF & _ " End Sub" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "Public Class Address" & @CRLF & _ " Public ClientId As String" & @CRLF & _ " Public PrimaryLine As String" & @CRLF & _ " Public SecondaryLine As String" & @CRLF & _ " Public City As String" & @CRLF & _ " Public State As String" & @CRLF & _ " Public ZipCode As String" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "Public Class Remits" & @CRLF & _ " Public UserId As String" & @CRLF & _ " Public Letters As List(Of Letter)" & @CRLF & _ "" & @CRLF & _ " Public Sub New()" & @CRLF & _ " Letters = New List(Of Letter)()" & @CRLF & _ " End Sub" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "Public Class Letter" & @CRLF & _ " Public ClientId As String" & @CRLF & _ " Public CustomerId As String" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "======================" & @CRLF & _ "C:\Users\Avell\Documents\workingfolder\M3\src\M3.WebSite\customerservice\aging\clientdocumentsedit.aspx.vb" & @CRLF & _ "Public Class LobTrackEvent" & @CRLF & _ " Public Id As String" & @CRLF & _ " Public Name As String" & @CRLF & _ " Public Location As String" & @CRLF & _ " Public Time As DateTime" & @CRLF & _ "" & @CRLF & _ " <JsonProperty("date_created")> Public Created As DateTime" & @CRLF & _ " <JsonProperty("date_modified")> Public Modified As DateTime" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "======================" & @CRLF & _ "C:\Users\Avell\Documents\workingfolder\M3\src\M3.WebSite\customerservice\customerremitnoa\clientinformationedit.aspx.vb" & @CRLF & _ "Public Class AddressVerificationResponse" & @CRLF & _ " <JsonProperty("id")> Public Id As String" & @CRLF & _ " <JsonProperty("recipient")> Public Recipient As String" & @CRLF & _ " <JsonProperty("primary_line")> Public PrimaryLine As String" & @CRLF & _ " <JsonProperty("secondary_line")> Public SecondaryLine As String" & @CRLF & _ " <JsonProperty("urbanization")> Public Urbanization As String" & @CRLF & _ " <JsonProperty("last_line")> Public LastLine As String" & @CRLF & _ " <JsonProperty("deliverability")> Public Deliverability As String" & @CRLF & _ " <JsonProperty("components")> Public Components As Components" & @CRLF & _ " <JsonProperty("deliverability_analysis")> Public DeliverabilityAnalysis As DeliverabilityAnalysis" & @CRLF & _ " <JsonProperty("object")> Public StrObject As String" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "Public Class Components" & @CRLF & _ " <JsonProperty("primary_number")> Public PrimaryNumber As String" & @CRLF & _ " <JsonProperty("street_predirection")> Public StreetPredirection As String" & @CRLF & _ " <JsonProperty("street_name")> Public StreetName As String" & @CRLF & _ " <JsonProperty("street_suffix")> Public StreetSuffix As String" & @CRLF & _ " <JsonProperty("street_postdirection")> Public StreetPostdirection As String" & @CRLF & _ " <JsonProperty("secondary_designator")> Public SecondaryDesignator As String" & @CRLF & _ " <JsonProperty("secondary_number")> Public SecondaryNumber As String" & @CRLF & _ " <JsonProperty("pmb_designator")> Public PmbDesignator As String" & @CRLF & _ " <JsonProperty("pmb_number")> Public PmbNumber As String" & @CRLF & _ " <JsonProperty("extra_secondary_information")> Public ExtraSecondaryInformation As String" & @CRLF & _ " <JsonProperty("city")> Public City As String" & @CRLF & _ " <JsonProperty("state")> Public State As String" & @CRLF & _ " <JsonProperty("zip_code")> Public ZipCode As String" & @CRLF & _ " <JsonProperty("zip_code_plus_4")> Public ZipCodePlus4 As String" & @CRLF & _ " <JsonProperty("zip_code_type")> Public ZipCodeType As String" & @CRLF & _ " <JsonProperty("delivery_point_barcode")> Public DeliveryPointBarcode As String" & @CRLF & _ " <JsonProperty("address_type")> Public AddressType As String" & @CRLF & _ " <JsonProperty("record_type")> Public RecordType As String" & @CRLF & _ " <JsonProperty("default_building_address")> Public DefaultBuildingAddress As Boolean" & @CRLF & _ " <JsonProperty("county")> Public County As String" & @CRLF & _ " <JsonProperty("county_fips")> Public CountyFips As String" & @CRLF & _ " <JsonProperty("carrier_route")> Public CarrierRoute As String" & @CRLF & _ " <JsonProperty("carrier_route_type")> Public CarrierRouteType As String" & @CRLF & _ " <JsonProperty("latitude")> Public Latitude As Object" & @CRLF & _ " <JsonProperty("longitude")> Public Longitude As Object" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "Public Class DeliverabilityAnalysis" & @CRLF & _ " <JsonProperty("dpv_confirmation")> Public DpvConfirmation As String" & @CRLF & _ " <JsonProperty("dpv_cmra")> Public DpvCmra As String" & @CRLF & _ " <JsonProperty("dpv_vacant")> Public DpvVacant As String" & @CRLF & _ " <JsonProperty("dpv_footnotes")> Public DpvFootnotes As Object()" & @CRLF & _ " <JsonProperty("ews_match")> Public EwsMatch As Boolean" & @CRLF & _ " <JsonProperty("lacs_indicator")> Public LacsIndicator As String" & @CRLF & _ " <JsonProperty("lacs_return_code")> Public LacsReturnCode As String" & @CRLF & _ " <JsonProperty("suite_return_code")> Public SuiteReturnCode As String" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "<Serializable> Public Class LegalAddressVerification" & @CRLF & _ " Private serviceAggrementValue As Boolean" & @CRLF & _ " Public Property ServiceAggrement() As Boolean" & @CRLF & _ " Get" & @CRLF & _ " Return serviceAggrementValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As Boolean)" & @CRLF & _ " serviceAggrementValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private serviceAggrementUserValue As String" & @CRLF & _ " Public Property ServiceAggrementUser() As String" & @CRLF & _ " Get" & @CRLF & _ " Return serviceAggrementUserValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As String)" & @CRLF & _ " serviceAggrementUserValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private serviceAggrementDateValue As DateTime" & @CRLF & _ " Public Property ServiceAggrementDate() As DateTime" & @CRLF & _ " Get" & @CRLF & _ " Return serviceAggrementDateValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As DateTime)" & @CRLF & _ " serviceAggrementDateValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private creditReportValue As Boolean" & @CRLF & _ " Public Property CreditReport() As Boolean" & @CRLF & _ " Get" & @CRLF & _ " Return creditReportValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As Boolean)" & @CRLF & _ " creditReportValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private creaditReportUserValue As String" & @CRLF & _ " Public Property CreditReportUser() As String" & @CRLF & _ " Get" & @CRLF & _ " Return creaditReportUserValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As String)" & @CRLF & _ " creaditReportUserValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private creditReportDateValue As DateTime" & @CRLF & _ " Public Property CreditReportDate() As DateTime" & @CRLF & _ " Get" & @CRLF & _ " Return creditReportDateValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As DateTime)" & @CRLF & _ " creditReportDateValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private invoiceValue As Boolean" & @CRLF & _ " Public Property Invoice() As Boolean" & @CRLF & _ " Get" & @CRLF & _ " Return invoiceValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As Boolean)" & @CRLF & _ " invoiceValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private invoiceUserValue As String" & @CRLF & _ " Public Property InvoiceUser() As String" & @CRLF & _ " Get" & @CRLF & _ " Return invoiceUserValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As String)" & @CRLF & _ " invoiceUserValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private invoiceDateValue As DateTime" & @CRLF & _ " Public Property InvoiceDate() As DateTime" & @CRLF & _ " Get" & @CRLF & _ " Return invoiceDateValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As DateTime)" & @CRLF & _ " invoiceDateValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private secretaryStateValue As Boolean" & @CRLF & _ " Public Property SecretaryState() As Boolean" & @CRLF & _ " Get" & @CRLF & _ " Return secretaryStateValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As Boolean)" & @CRLF & _ " secretaryStateValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private secretaryStateUserValue As String" & @CRLF & _ " Public Property SecretaryStateUser() As String" & @CRLF & _ " Get" & @CRLF & _ " Return secretaryStateUserValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As String)" & @CRLF & _ " secretaryStateUserValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "" & @CRLF & _ " Private secretaryStateDateValue As DateTime" & @CRLF & _ " Public Property SecretaryStateDate() As DateTime" & @CRLF & _ " Get" & @CRLF & _ " Return secretaryStateDateValue" & @CRLF & _ " End Get" & @CRLF & _ " Set(ByVal value As DateTime)" & @CRLF & _ " secretaryStateDateValue = value" & @CRLF & _ " End Set" & @CRLF & _ " End Property" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "=======================" & @CRLF & _ "C:\Users\Avell\Documents\workingfolder\M3\src\M3.WebSite\customerservice\customerremitnoa\generateletter.aspx.vb" & @CRLF & _ "Class RequestBody" & @CRLF & _ " Public ContactName As String" & @CRLF & _ " Public ContactEmail As String" & @CRLF & _ " Public File As String" & @CRLF & _ " Public SignatureRequestId As String" & @CRLF & _ "End Class" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" 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