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

/
/
gm

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?m) "name": "(.+)",(.*)|"endpoint": "(.*\..*)",`) var str = ` "name": "Arkane Network", "endpoint": "app.arkane.network ", "endpoint": "connect.arkane.network ", "endpoint": "login.arkane.network", "name": "Bpost2", "endpoint": "*.bpost2.be", "name": "Brussels Airlines", "endpoint": "bprofile.brusselsairlines.com", "endpoint": "www.brusselsairlines.com", "name": "De Morgen", "endpoint": "*.demorgen.be", "endpoint": "abonnement.demorgen.be", "endpoint": "login2.demorgen.be", "endpoint": "myaccount.demorgen.be", "endpoint": "shop.demorgen.be", "endpoint": "www.demorgen.be", "name": "Delen Private Bank", "endpoint": "api.digital.delen.be ", "endpoint": "api.digital.delen.lu ", "endpoint": "app.delen.be ", "endpoint": "app.delen.ch ", "endpoint": "app.delen.lu ", "endpoint": "auth.digital.delen.be ", "endpoint": "auth.digital.delen.lu ", "endpoint": "be.delen.digital", "endpoint": "login.delen.be ", "endpoint": "login.delen.ch ", "endpoint": "login.delen.lu ", "endpoint": "login.oyens.com", "endpoint": "status.delen.be ", "endpoint": "sts.delen.be ", "endpoint": "www.cadelam.be ", "endpoint": "www.cadelux.lu/en ", "endpoint": "www.delen.be/en ", "name": "EURid", "endpoint": "*.das.eu", "endpoint": "*.dns.eu", "endpoint": "*.eurid.eu", "endpoint": "*.nic.eu", "endpoint": "*.registry.eu", "endpoint": "*.whois.eu", "name": "GULP", "endpoint": "www.gulp-shop.de", "endpoint": "*.gulp.ch", "endpoint": "*.gulp.de", "endpoint": "demo.tendertracker.de", "name": "Hardware Info", "endpoint": " *.hardware.info ", "endpoint": "*.hwigroup.com", "endpoint": "*.hwigroup.net ", "name": "Hoplr", "endpoint": "www.hoplr.com", "endpoint": "*.hoplr.*", "endpoint": "com.hoplr", "name": "IAM KU Leuven", "endpoint": " account.kuleuven.be", "endpoint": " idp.kuleuven.be", "name": "Jooki", "endpoint": "*.jooki.rocks", "endpoint": "*.muuselabs.com", "endpoint": "my.jooki.rocks", "name": "KU Leuven - www.kuleuven.be", "endpoint": "www.kuleuven.be/english/", "endpoint": "www.kuleuven.be", "name": "Monster Worldwide", "endpoint": "*.military.com", "endpoint": "*.monster.at", "endpoint": "*.monster.be", "endpoint": "*.monster.ca", "endpoint": "*.monster.ch", "endpoint": "*.monster.co.uk", "endpoint": "*.monster.com", "endpoint": "*.monster.cz", "endpoint": "*.monster.de", "endpoint": "*.monster.dk", "endpoint": "*.monster.es", "endpoint": "*.monster.eu", "endpoint": "*.monster.fi", "endpoint": "*.monster.fr", "endpoint": "*.monster.hu", "endpoint": "*.monster.ie", "endpoint": "*.monster.it", "endpoint": "*.monster.lu", "endpoint": "*.monster.no", "endpoint": "*.monster.pt", "endpoint": "*.monster.se", "endpoint": "*.monsterboard.nl", "endpoint": "*.monsterpolska.pl", "name": "Nexuzhealth", "endpoint": "mobile.nexuzhealth.be", "endpoint": "mynexuz.be", "endpoint": "mynexuz.be/myUZ/", "endpoint": "www.nexuzhealth.be/en", "name": "Nexuzhealth Web PACS", "endpoint": " idp-contact.nexuzhealth.be", "endpoint": "media.nexuzhealth.be/patient/ ", "name": "Online enrollment for students", "endpoint": "https://associatie.kuleuven.be/inschrijvingen/oli_login_50000050", "endpoint": "https://webwsp.aps.kuleuven.be/sap/bc/ui5_ui5/sap/zc_oi_appl/", "name": "Phished", "endpoint": "*.phished.be", "name": "Port of Antwerp", "endpoint": "*.c-point.be", "endpoint": "*.portofantwerp.com", "name": "Randstad", "endpoint": "*.randstadrisesmart.*", "endpoint": "*.risesmart.*", "endpoint": "*.randstad.*", , "name": "Red Bull", "endpoint": "*.redbull.com", "name": "Sentiance", "endpoint": "*.sentiance.com", "endpoint": "docs.sentiance.com", "name": "Speakap Responsible Disclosure", "endpoint": "*.speakap.com", "endpoint": "*.speakap.io", "name": "Suivo", "endpoint": " aweb.suivo.com", "endpoint": "asupport.suivo.com", "name": "Telenet - Base ", "endpoint": "https://www2.telenet.be/nl/landing-pages/safespot", "endpoint": "*.9lives.be", "endpoint": "*.base.be", "endpoint": "*.telenet.be", "endpoint": "*.telenethotspot.be ", "endpoint": "*.yelo.be", "endpoint": "*.yeloplay.be", "name": "Tempo-Team ", "endpoint": "www.tempo-team.com", "endpoint": "www.tempo-team.nl", "endpoint": "www.tempo-team.be", "endpoint": "*.tempo-team.*", "name": "Tomorrowland", "endpoint": "artists.tomorrowland.com/production-website/33117", "endpoint": "cognito-idp.eu-west-1.amazonaws.com", "endpoint": "globaljourney.tomorrowland.com", "endpoint": "mdm.weareone.world", "endpoint": "my.tomorrowland.com", "endpoint": "oneworldradio.tomorrowland.com", "endpoint": "sp1y1tpaf1.execute-api.eu-west-1.amazonaws.com", "endpoint": "winterpackages.tomorrowland.com", "endpoint": "www.tomorrowland.com", "name": "Torfs", "endpoint": "winkels.torfs.be", "endpoint": "www.schoenentorfs.be", "endpoint": "www.schoenentorfs.nl ", "endpoint": "www.torfs.be", "endpoint": "www.torfs.nl", "endpoint": "www.samenfittorfs.be", "endpoint": "www.sterkinjeschoenen.be", "endpoint": "www.torfssuppliers.be", "name": "Trouw", "endpoint": "*.trouw.nl", "endpoint": "abonnement.trouw.nl", "endpoint": "login2.trouw.nl", "endpoint": "myaccount.trouw.nl", "endpoint": "shop.trouw.nl", "endpoint": "webwinkel.trouw.nl", "endpoint": "www.trouw.nl", "name": "Twago", "endpoint": "*.twago.fr", "endpoint": "*.twago.it", "endpoint": "*.twago.com", "endpoint": "*.twago.de", "endpoint": "*.twago.es", "name": "Tweakers", "endpoint": "*.tweakblogs.net", "endpoint": "*.tweakers.net", "endpoint": "*.tweakimg.net", "name": "UZ Leuven", "endpoint": "www.uzleuven.be/en", "name": "VRT", "endpoint": "*.canvas.be", "endpoint": "*.dewarmsteweek.be", "endpoint": "*.een.be", "endpoint": "*.ketnet.be", "endpoint": "*.klara.be", "endpoint": "*.mnm.be", "endpoint": "*.radio1.be", "endpoint": "*.radio2.be", "endpoint": "*.sporza.be", "endpoint": "*.stubru.be", "endpoint": "*.vrt.be", "endpoint": "be.vrt.ketnet.ketnet", "name": "VTM GO", "endpoint": "login2.vtm.be", "endpoint": "myaccount.vtm.be", "endpoint": "vtm.be/vtmgo", "endpoint": "vtmgo.be", "endpoint": "*.vtm.be", "endpoint": "*.vtmgo.be", "name": "eHealth Hub VZN KUL", "endpoint": "hub.vznkul.be/services/intrahub/IntraHubService", "endpoint": "hub.vznkul.be/services/interhub/InterHubService", "endpoint": "hubacc.vznkul.be/services/acceptance/intrahub/IntraHubService", "endpoint": "hubacc.vznkul.be/services/acceptance/interhub/InterHubService", "endpoint": "hub.vznkul.be/* ", "endpoint": "hubacc.vznkul.be/*", "name": "iBOOD.com", "endpoint": "www.ibood.com", "name": "intigriti", "endpoint": "*.intigriti.com", "endpoint": "*.intigriti.io", "endpoint": "*.intigriti.me", "name": "itsme", "endpoint": "mobileapp.itsme.be", "endpoint": "business.itsme.be/en/", "endpoint": "confluence.belgianmobileid.be", "endpoint": "crowd.belgianmobileid.be", "endpoint": "jira.belgianmobileid.be", "endpoint": "merchant.itsme.be", "endpoint": "my.itsme.be", "endpoint": "www.belgianmobileid.be/en/", "endpoint": "www.itsme.be/en/", ` for i, match := range re.FindAllString(str, -1) { fmt.Println(match, "found at index", i) } }

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 Golang, please visit: https://golang.org/pkg/regexp/