Regular Expressions 101

Save & Share

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

/
/
gxm

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 = "(?xm)^(((((.+\.)*(msedge))|((((.+\.)*(scsquery\-ss\-us))|((.+\.)*(scsquery\-ss\-eu))|((.+\.)*(scsquery\-ss\-asia))|((.+\.)*(scsinstrument\-ss\-us))|((.+\.)*(skypemaprdsitus)))\.(trafficmanager))|((.+\.)*(msftauth))|((((((((.+\.)*(policykeyservice)))\.(dc)))\.(ad)))\.(msft))|((.+\.)*(phonefactor))|((((((((.+\.)*(informationprotection)))\.(hosting)))\.(portal))|((.+\.)*(amp)))\.(azure))|((((((.+\.)*(ecn)))\.(dev)))\.(virtualearth))|((((.+\.)*(apis)))\.(live))|((((.+\.)*(spoprod\-a)))\.(akamaihd))|((((.+\.)*(cdn)))\.(onenote))|((.+\.)*(msecnd))|((.+\.)*(msftauthimages))|((((((((.+\.)*(officecdn)))\.(microsoft)))\.(com)))\.(edgesuite))|((.+\.)*(msauth))|((((.+\.)*(mlccdnprod)))\.(azureedge))|((.+\.)*(msauthimages))|((((((.+\.)*(insertmedia)))\.(bing))|((((.+\.)*(videocontent))|((.+\.)*(videoplayercdn))|((.+\.)*(contentstorage))|((.+\.)*(video)))\.(osi))|((((.+\.)*(support)))\.(content))|((.+\.)*(cdn))|((.+\.)*(attachments))|((.+\.)*(suite)))\.(office))|((.+\.)*(windows)))\.(net))|((((((.+\.)*(appsforoffice))|((.+\.)*(c1))|((.+\.)*(crl))|((((.+\.)*(r)))\.(office))|((.+\.)*(aria))|((.+\.)*(technet))|((.+\.)*(officecdn))|((.+\.)*(officeredir))|((.+\.)*(officepreviewredir))|((.+\.)*(office15client))|((.+\.)*(go))|((.+\.)*(msdn))|((((.+\.)*(activation)))\.(sls))|((.+\.)*(support))|((.+\.)*(compass\-ssl))|((.+\.)*(docs))|((((.+\.)*(events)))\.(data))|((.+\.)*(officeclient)))\.(microsoft))|((.+\.)*(outlook))|((.+\.)*(microsoftonline))|((((.+\.)*(secure)))\.(skypeassets))|((.+\.)*(sharepointonline))|((((.+\.)*(informationprotection))|((.+\.)*(management))|((.+\.)*(adhybridhealth)))\.(azure))|((((.+\.)*(g))|((.+\.)*(officeapps))|((((.+\.)*(client)))\.(hip)))\.(live))|((.+\.)*(onenote))|((((.+\.)*(\-myfiles))|((.+\.)*(\-files)))\.(sharepoint))|((((.+\.)*(admin))|((.+\.)*(www)))\.(onedrive))|((.+\.)*(o365weve))|((((.+\.)*(platform)))\.(linkedin))|((.+\.)*(azurerms))|((((.+\.)*(prod))|((.+\.)*(shellprod)))\.(msocdn))|((.+\.)*(microsoftonline\-p))|((((.+\.)*(cdn)))\.(optimizely))|((((.+\.)*(quicktips)))\.(skypeforbusiness))|((((.+\.)*(ajax)))\.(aspnetcdn))|((.+\.)*(aadrm))|((((.+\.)*(products))|((.+\.)*(delve\-gcc))|((.+\.)*(support))|((.+\.)*(templates))|((.+\.)*(outlook))|((.+\.)*(delve))|((((.+\.)*(webshell)))\.(suite)))\.(office))|((.+\.)*(office365))|((.+\.)*(sfbassets))|((((((.+\.)*(skydrive)))\.(wns)))\.(windows))|((.+\.)*(skype)))\.(com))|((((.+\.)*(svc))|((((.+\.)*(auth)))\.(gfx))|((.+\.)*(aka))|((.+\.)*(mstea))|((((.+\.)*(assets)))\.(onestore))|((((.+\.)*(oneclient)))\.(sfx)))\.(ms)))$ " Local $sString = "aadrm.com" & @CRLF & _ "account.activedirectory.windowsazure.com" & @CRLF & _ "acompli.net" & @CRLF & _ "ad.atdmt.com" & @CRLF & _ "adhybridhealth.azure.com" & @CRLF & _ "adl.windows.com" & @CRLF & _ "ajax.aspnetcdn.com" & @CRLF & _ "aka.ms" & @CRLF & _ "appex-rf.msn.com" & @CRLF & _ "assets.onestore.ms" & @CRLF & _ "assets-yammer.com" & @CRLF & _ "atp.azure.com" & @CRLF & _ "auth.gfx.ms" & @CRLF & _ "autologon.microsoftazuread-sso.com" & @CRLF & _ "azure.net" & @CRLF & _ "azureedge.net" & @CRLF & _ "azurerms.com" & @CRLF & _ "bing.com" & @CRLF & _ "bit.ly" & @CRLF & _ "by.uservoice.com" & @CRLF & _ "c.bing.net" & @CRLF & _ "cdn.optimizely.com" & @CRLF & _ "clientconfig.microsoftonline-p.net" & @CRLF & _ "cloudapp.net" & @CRLF & _ "ctldl.windowsupdate.com" & @CRLF & _ "dc.services.visualstudio.com" & @CRLF & _ "ecn.dev.virtualearth.net" & @CRLF & _ "eus-www.sway-cdn.com" & @CRLF & _ "eus-www.sway-extensions.com" & @CRLF & _ "excelbingmap.firstpartyapps.oaspapps.com" & @CRLF & _ "firstpartyapps.oaspapps.com" & @CRLF & _ "graph.facebook.com" & @CRLF & _ "hockeyapp.net" & @CRLF & _ "informationprotection.azure.com" & @CRLF & _ "isrg.trustid.ocsp.identrust.com" & @CRLF & _ "live.com" & @CRLF & _ "" & @CRLF & _ "live.net" & @CRLF & _ "login.windows-ppe.net" & @CRLF & _ "lync.com" & @CRLF & _ "management.azure.com" & @CRLF & _ "mem.gfx.ms" & @CRLF & _ "microsoft.com" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "microsoftonline.com" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "microsoftonline-p.com" & @CRLF & _ "" & @CRLF & _ "microsoftstream.com" & @CRLF & _ "msappproxy.net" & @CRLF & _ "msauth.net" & @CRLF & _ "msauthimages.net" & @CRLF & _ "msecnd.net" & @CRLF & _ "msedge.net" & @CRLF & _ "msftauth.net" & @CRLF & _ "msftauthimages.net" & @CRLF & _ "msftidentity.com" & @CRLF & _ "msidentity.com" & @CRLF & _ "msocdn.com" & @CRLF & _ "mstea.ms" & @CRLF & _ "o365weve.com" & @CRLF & _ "office.com" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "office.net" & @CRLF & _ "office365.com" & @CRLF & _ "" & @CRLF & _ "officecdn.microsoft.com.edgesuite.net" & @CRLF & _ "oneclient.sfx.ms" & @CRLF & _ "onedrive.com" & @CRLF & _ "onenote.com" & @CRLF & _ "onmicrosoft.com" & @CRLF & _ "outlook.com" & @CRLF & _ "" & @CRLF & _ "outlook.uservoice.com" & @CRLF & _ "outlookmobile.com" & @CRLF & _ "partnerservices.getmicrosoftkey.com" & @CRLF & _ "peoplegraph.firstpartyapps.oaspapps.com" & @CRLF & _ "phonefactor.net" & @CRLF & _ "policykeyservice.dc.ad.msft.net" & @CRLF & _ "portal.cloudappsecurity.com" & @CRLF & _ "prod.firstpartyapps.oaspapps.com.akadns.net" & @CRLF & _ "secure.skypeassets.com" & @CRLF & _ "sfbassets.com" & @CRLF & _ "sharepoint.com" & @CRLF & _ "sharepointonline.com" & @CRLF & _ "skydrive.wns.windows.com" & @CRLF & _ "skype.com" & @CRLF & _ "" & @CRLF & _ "skypeforbusiness.com" & @CRLF & _ "social.yahooapis.com" & @CRLF & _ "spoprod-a.akamaihd.net" & @CRLF & _ "staffhub.ms" & @CRLF & _ "staffhub.uservoice.com" & @CRLF & _ "svc.ms" & @CRLF & _ "sway.com" & @CRLF & _ "symcb.com" & @CRLF & _ "symcd.com" & @CRLF & _ "telemetryservice.firstpartyapps.oaspapps.com" & @CRLF & _ "trafficmanager.net" & @CRLF & _ "tse1.mm.bing.net" & @CRLF & _ "view.atdmt.com" & @CRLF & _ "wikipedia.firstpartyapps.oaspapps.com" & @CRLF & _ "windows.net" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "windowsupdate.com" & @CRLF & _ "wus-firstpartyapps.oaspapps.com" & @CRLF & _ "wus-www.sway-cdn.com" & @CRLF & _ "wus-www.sway-extensions.com" & @CRLF & _ "yammer.com" & @CRLF & _ "yammerusercontent.com" & @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