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

$re = '/^(((((.+\.)*(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)))$ /xm'; $str = 'aadrm.com account.activedirectory.windowsazure.com acompli.net ad.atdmt.com adhybridhealth.azure.com adl.windows.com ajax.aspnetcdn.com aka.ms appex-rf.msn.com assets.onestore.ms assets-yammer.com atp.azure.com auth.gfx.ms autologon.microsoftazuread-sso.com azure.net azureedge.net azurerms.com bing.com bit.ly by.uservoice.com c.bing.net cdn.optimizely.com clientconfig.microsoftonline-p.net cloudapp.net ctldl.windowsupdate.com dc.services.visualstudio.com ecn.dev.virtualearth.net eus-www.sway-cdn.com eus-www.sway-extensions.com excelbingmap.firstpartyapps.oaspapps.com firstpartyapps.oaspapps.com graph.facebook.com hockeyapp.net informationprotection.azure.com isrg.trustid.ocsp.identrust.com live.com live.net login.windows-ppe.net lync.com management.azure.com mem.gfx.ms microsoft.com microsoftonline.com microsoftonline-p.com microsoftstream.com msappproxy.net msauth.net msauthimages.net msecnd.net msedge.net msftauth.net msftauthimages.net msftidentity.com msidentity.com msocdn.com mstea.ms o365weve.com office.com office.net office365.com officecdn.microsoft.com.edgesuite.net oneclient.sfx.ms onedrive.com onenote.com onmicrosoft.com outlook.com outlook.uservoice.com outlookmobile.com partnerservices.getmicrosoftkey.com peoplegraph.firstpartyapps.oaspapps.com phonefactor.net policykeyservice.dc.ad.msft.net portal.cloudappsecurity.com prod.firstpartyapps.oaspapps.com.akadns.net secure.skypeassets.com sfbassets.com sharepoint.com sharepointonline.com skydrive.wns.windows.com skype.com skypeforbusiness.com social.yahooapis.com spoprod-a.akamaihd.net staffhub.ms staffhub.uservoice.com svc.ms sway.com symcb.com symcd.com telemetryservice.firstpartyapps.oaspapps.com trafficmanager.net tse1.mm.bing.net view.atdmt.com wikipedia.firstpartyapps.oaspapps.com windows.net windowsupdate.com wus-firstpartyapps.oaspapps.com wus-www.sway-cdn.com wus-www.sway-extensions.com yammer.com yammerusercontent.com '; 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