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)^(?<vendor_date>\d{4}(?:\-\d\d){2} [^,]+,[^:]+):(?<vendor_level>[^:]+):(?<vendor_component>[^:]+):(?<vendor_message>[^\n\r]+)(?<vendor_details>(?(?=^\d{4}(?:\-\d\d){2})|[^\r])+)?" Local $sString = "2019-10-14 11:07:08,727:DEBUG:certbot.cli:Var dry_run=True (set by user)." & @CRLF & _ "2019-10-14 11:07:08,727:DEBUG:certbot.cli:Var server={'dry_run', 'staging'} (set by user)." & @CRLF & _ "2019-10-14 11:07:08,727:DEBUG:certbot.cli:Var dry_run=True (set by user)." & @CRLF & _ "2019-10-14 11:07:08,728:DEBUG:certbot.cli:Var server={'dry_run', 'staging'} (set by user)." & @CRLF & _ "2019-10-14 11:07:08,728:DEBUG:certbot.cli:Var account={'server'} (set by user)." & @CRLF & _ "2019-10-14 11:07:08,757:INFO:certbot.renewal:Cert not due for renewal, but simulating renewal for dry run" & @CRLF & _ "2019-10-14 11:07:08,757:DEBUG:certbot.plugins.selection:Requested authenticator nginx and installer nginx" & @CRLF & _ "2019-10-14 11:07:10,881:DEBUG:certbot.plugins.selection:Single candidate plugin: * nginx" & @CRLF & _ "Description: Nginx Web Server plugin" & @CRLF & _ "Interfaces: IAuthenticator, IInstaller, IPlugin" & @CRLF & _ "Entry point: nginx = certbot_nginx.configurator:NginxConfigurator" & @CRLF & _ "Initialized: " & @CRLF & _ "Prep: True" & @CRLF & _ "2019-10-14 11:07:10,888:DEBUG:certbot.plugins.selection:Single candidate plugin: * nginx" & @CRLF & _ "Description: Nginx Web Server plugin" & @CRLF & _ "Interfaces: IAuthenticator, IInstaller, IPlugin" & @CRLF & _ "Entry point: nginx = certbot_nginx.configurator:NginxConfigurator" & @CRLF & _ "Initialized: " & @CRLF & _ "Prep: True" & @CRLF & _ "2019-10-14 11:07:10,889:DEBUG:certbot.plugins.selection:Selected authenticator and installer " & @CRLF & _ "2019-10-14 11:07:10,889:INFO:certbot.plugins.selection:Plugins selected: Authenticator nginx, Installer nginx" & @CRLF & _ "2019-10-14 11:07:10,902:DEBUG:certbot.main:Picked account: )>), only_return_existing=None, contact=('mailto:trol@yopmail.com',), agreement='https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf')), 019763ae9d0030f2ffa8f8cb689e7976, Meta(creation_dt=datetime.datetime(2018, 2, 27, 14, 17, 55, tzinfo=), creation_host='sd-99715.dedibox.fr'))>" & @CRLF & _ "2019-10-14 11:07:10,911:DEBUG:acme.client:Sending GET request to https://acme-staging-v02.api.letsencrypt.org/directory." & @CRLF & _ "2019-10-14 11:07:10,998:DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org" & @CRLF & _ "2019-10-14 11:07:14,617:DEBUG:requests.packages.urllib3.connectionpool:https://acme-staging-v02.api.letsencrypt.org:443 "GET /directory HTTP/1.1" 200 724" & @CRLF & _ "2019-10-14 11:07:14,619:DEBUG:acme.client:Received response:" & @CRLF & _ "HTTP 200" & @CRLF & _ "Server: nginx" & @CRLF & _ "Date: Mon, 14 Oct 2019 09:07:14 GMT" & @CRLF & _ "Content-Type: application/json" & @CRLF & _ "Content-Length: 724" & @CRLF & _ "Connection: keep-alive" & @CRLF & _ "Cache-Control: public, max-age=0, no-cache" & @CRLF & _ "X-Frame-Options: DENY" & @CRLF & _ "Strict-Transport-Security: max-age=604800" & @CRLF & _ "{" & @CRLF & _ " "kRr68eKT_x4": "https://community.letsencrypt.org/t/adding-random-entries-to-the-directory/33417"," & @CRLF & _ " "keyChange": "https://acme-staging-v02.api.letsencrypt.org/acme/key-change"," & @CRLF & _ " "meta": {" & @CRLF & _ " "caaIdentities": [" & @CRLF & _ " "letsencrypt.org"" & @CRLF & _ " ]," & @CRLF & _ " "termsOfService": "https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf"," & @CRLF & _ " "website": "https://letsencrypt.org/docs/staging-environment/"" & @CRLF & _ " }," & @CRLF & _ " "newAccount": "https://acme-staging-v02.api.letsencrypt.org/acme/new-acct"," & @CRLF & _ " "newNonce": "https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce"," & @CRLF & _ " "newOrder": "https://acme-staging-v02.api.letsencrypt.org/acme/new-order"," & @CRLF & _ " "revokeCert": "https://acme-staging-v02.api.letsencrypt.org/acme/revoke-cert"" & @CRLF & _ "}" & @CRLF & _ "2019-10-14 11:07:14,620:INFO:certbot.main:Renewing an existing certificate" & @CRLF & _ "2019-10-14 11:07:14,999:DEBUG:acme.client:Requesting fresh nonce" & @CRLF & _ "2019-10-14 11:07:15,006:DEBUG:acme.client:Sending HEAD request to https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce." & @CRLF & _ "2019-10-14 11:07:15,156:DEBUG:requests.packages.urllib3.connectionpool:https://acme-staging-v02.api.letsencrypt.org:443 "HEAD /acme/new-nonce HTTP/1.1" 200 0" & @CRLF & _ "2019-10-14 11:07:15,158:DEBUG:acme.client:Received response:" & @CRLF & _ "HTTP 200" & @CRLF & _ "Server: nginx" & @CRLF & _ "Date: Mon, 14 Oct 2019 09:07:15 GMT" & @CRLF & _ "Connection: keep-alive" & @CRLF & _ "Cache-Control: public, max-age=0, no-cache" & @CRLF & _ "Link: https://acme-staging-v02.api.letsencrypt.org/directory;rel="index"" & @CRLF & _ "Replay-Nonce: 0002fqXrdxZwV_xxxxx-xxxxxxxx-KdWhvOCtgFh5YNNVM" & @CRLF & _ "X-Frame-Options: DENY" & @CRLF & _ "Strict-Transport-Security: max-age=604800" & @CRLF & _ "2019-10-14 11:07:15,158:DEBUG:acme.client:Storing nonce: 0002fqXrdxZwV_xxxxx-xxxxxxxx-KdWhvOCtgFh5YNNVM " & @CRLF & _ "2019-10-14 11:07:15,160:DEBUG:acme.client:JWS payload:" & @CRLF & _ "b'{\n "identifiers": [\n {\n "type": "dns",\n "value": "site.tld"\n },\n {\n "type": "dns",\n "value": "cdn-css. site.tld "\n },\n {\n "type": "dns",\n "value": "cdn-js-body. site.tld "\n },\n {\n "type": "dns",\n "value": "cdn-js-footer. site.tld "\n },\n {\n "type": "dns",\n "value": "cdn-js-head. site.tld "\n },\n {\n "type": "dns",\n "value": "www. site.tld "\n }\n ]\n}'" & @CRLF & _ "2019-10-14 11:07:15,173:DEBUG:acme.client:Sending POST request to https://acme-staging-v02.api.letsencrypt.org/acme/new-order:" & @CRLF & _ "{" & @CRLF & _ " "protected": "SOmeBASE64Str"," & @CRLF & _ " "payload": "ANOTHERB64STR"," & @CRLF & _ " "signature": "YETANOTHERB64STR"" & @CRLF & _ "}" & @CRLF & _ "2019-10-14 11:07:15,387:DEBUG:requests.packages.urllib3.connectionpool:https://acme-staging-v02.api.letsencrypt.org:443 "POST /acme/new-order HTTP/1.1" 201 1104" 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