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

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)<link rel="canonical" href="(.*?)">" Local $sString = "const regex = /"sku": "(.*?)"/gm;" & @CRLF & _ "" & @CRLF & _ "// Alternative syntax using RegExp constructor" & @CRLF & _ "// const regex = new RegExp('"sku": "(.*?)"', 'gm')" & @CRLF & _ "" & @CRLF & _ "const str = ``<!DOCTYPE html>" & @CRLF & _ "<!-- saved from url=(0044)https://www.daz3d.com/karmen-9-hd-pro-bundle -->" & @CRLF & _ "<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class=""><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">" & @CRLF & _ "" & @CRLF & _ "<title>Karmen 9 HD Pro Bundle | Daz 3D</title>" & @CRLF & _ "<meta name="viewport" content="width=device-width, initial-scale=1">" & @CRLF & _ "<meta name="description" content="&lt;p&gt;Introducing the Karmen 9 HD Pro Bundle. This all-inclusive bundle features a vibrant makeup look, expressions, a curly and braided bun hairstyle, apocalyptic-inspired outfits, Elemental Mage and Shadow Realm attire, and even monstrous poses to immerse ">" & @CRLF & _ "<meta name="keywords" content="Karmen 9 HD Pro Bundle">" & @CRLF & _ "<meta http-equiv="X-UA-Compatible" content="IE=edge">" & @CRLF & _ "<meta name="robots" content="INDEX,FOLLOW,noai, noimageai">" & @CRLF & _ "<link rel="icon" href="https://www.daz3d.com/static/images/favicon.ico" type="image/x-icon">" & @CRLF & _ "<link rel="shortcut icon" href="https://www.daz3d.com/static/images/favicon.ico" type="image/x-icon">" & @CRLF & _ "<!--[if lt IE 7]>" & @CRLF & _ "<script type="text/javascript">" & @CRLF & _ "//<![CDATA[" & @CRLF & _ " var BLANK_URL = '/js/blank.html';" & @CRLF & _ " var BLANK_IMG = '/js/spacer.gif';" & @CRLF & _ "//]]>" & @CRLF & _ "</script>" & @CRLF & _ "<![endif]-->" & @CRLF & _ "<link rel="stylesheet" href="./Karmen 9 HD Pro Bundle _ Daz 3D_files/design-533ce80c63b6085aedc802b14d1faa79.css" about="0">" & @CRLF & _ "<link rel="stylesheet" href="./Karmen 9 HD Pro Bundle _ Daz 3D_files/product_zoom-5de5dd875434871413473d85f684dcfc.css" about="1">" & @CRLF & _ "<style>" & @CRLF & _ " @keyframes spinner {" & @CRLF & _ " 0% {" & @CRLF & _ " transform: translateY(-50%) rotate(0deg);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " 100% {" & @CRLF & _ " transform: translateY(-50%) rotate(360deg);" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " .spinner::after {" & @CRLF & _ " animation: 1.5s linear infinite spinner;" & @CRLF & _ " animation-play-state: inherit;" & @CRLF & _ " border: solid 3px #cfd0d1;" & @CRLF & _ " border-bottom-color: #1c87c9;" & @CRLF & _ " border-radius: 50%;" & @CRLF & _ " content: "";" & @CRLF & _ " height: 20px;" & @CRLF & _ " width: 20px;" & @CRLF & _ " display: inline-flex;" & @CRLF & _ " flex-direction: column;" & @CRLF & _ " padding-bottom: 5px;" & @CRLF & _ " }" & @CRLF & _ " </style>" & @CRLF & _ "<script src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/getIds" type="text/javascript" async=""></script><script type="text/javascript" id="www-widgetapi-script" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/www-widgetapi.js.download" async=""></script><script async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/fbevents.js.download"></script><script type="text/javascript" async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/bat.js.download"></script><script type="text/javascript" async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/pixel.js.download"></script><script type="text/javascript" async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/analytics.js.download"></script><script type="text/javascript" async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/js"></script><script type="text/javascript" async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/destination"></script><script src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/tag.js.download" type="text/javascript" async="" id="cjapitag"></script><script async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/affirm.js.download"></script><script type="text/javascript" async="" src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/0"></script><script src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/core-ed1ca31447e4f2e9bbf6d9ef38afe3c6.js.download"></script>" & @CRLF & _ "<style>" & @CRLF & _ " @keyframes spinner {" & @CRLF & _ " 0% {" & @CRLF & _ " transform: translateY(-50%) rotate(0deg);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " 100% {" & @CRLF & _ " transform: translateY(-50%) rotate(360deg);" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " .spinner::after {" & @CRLF & _ " animation: 1.5s linear infinite spinner;" & @CRLF & _ " animation-play-state: inherit;" & @CRLF & _ " border: solid 3px #cfd0d1;" & @CRLF & _ " border-bottom-color: #1c87c9;" & @CRLF & _ " border-radius: 50%;" & @CRLF & _ " content: "";" & @CRLF & _ " height: 20px;" & @CRLF & _ " width: 20px;" & @CRLF & _ " display: inline-flex;" & @CRLF & _ " flex-direction: column;" & @CRLF & _ " padding-bottom: 5px;" & @CRLF & _ " }" & @CRLF & _ " </style>" & @CRLF & _ "<script src="./Karmen 9 HD Pro Bundle _ Daz 3D_files/zoom-fee76dde1f2c855960b29036b231c115.js.download"></script>" & @CRLF & _ "<script type="application/ld+json">{" & @CRLF & _ " "brand": {" & @CRLF & _ " "name": "Daz 3D"," & @CRLF & _ " "@type": "Brand"" & @CRLF & _ " }," & @CRLF & _ " "@context": "https://schema.org/"," & @CRLF & _ " "description": "Introducing the Karmen 9 HD Pro Bundle. This all-inclusive bundle features a vibrant makeup look, expressions, a curly and braided bun hairstyle, apocalyptic-inspired outfits, Elemental Mage and Shadow Realm attire, and even monstrous poses to immerse your character into any narrative from modern desert to fantasy to horror."," & @CRLF & _ " "image": "https://gcdn.daz3d.com/p/91909/i/shimuzu_Karmen_Pro_Bundle.jpg"," & @CRLF & _ " "name": "Karmen 9 HD Pro Bundle"," & @CRLF & _ " "offers": {" & @CRLF & _ " "availability": "https://schema.org/InStock"," & @CRLF & _ " "itemCondition": "https://schema.org/NewCondition"," & @CRLF & _ " "price": 185.99," & @CRLF & _ " "priceCurrency": "USD"," & @CRLF & _ " "@type": "Offer"" & @CRLF & _ " }," & @CRLF & _ " "sku": "91909"," & @CRLF & _ " "@type": "Product"" & @CRLF & _ "}</script>" & @CRLF & _ "<link rel="canonical" href="https://www.daz3d.com/karmen-9-hd-pro-bundle">" & @CRLF & _ "<script>" & @CRLF & _ " if (!daz) { var daz = {}; };" & @CRLF & _ " daz.api = new DazApi()" & @CRLF & _ "" & @CRLF & _ " from 331.2deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 93% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 334.8deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 94% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 338.4deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 95% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 342deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 96% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 345.6deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 97% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 349.2deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 98% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 352.8deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 99% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 356.4deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " 100% {" & @CRLF & _ " border-image: conic-gradient(" & @CRLF & _ " from 360deg," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)," & @CRLF & _ " var(--border-color-2)," & @CRLF & _ " var(--border-color-1)" & @CRLF & _ " )" & @CRLF & _ " 1;" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /* END rotate bonus box border */" & @CRLF & _ " /* BEGIN falling stars animation */" & @CRLF & _ "" & @CRLF & _ " .bg-stars {" & @CRLF & _ " width: 100%;" & @CRLF & _ " height: 100%;" & @CRLF & _ " position: absolute;" & @CRLF & _ " top: 0;" & @CRLF & _ " left: 0;" & @CRLF & _ " overflow: hidden;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " .bg-stars .bg-star {" & @CRLF & _ " font-size: 1em;" & @CRLF & _ " position: absolute;" & @CRLF & _ " top: -25px;" & @CRLF & _ " color: yellow;" & @CRLF & _ " user-select: none;" & @CRLF & _ " cursor: default;" & @CRLF & _ " text-shadow: 0 0 1px #000;" & @CRLF & _ " animation-name: fallingStars;" & @CRLF & _ " animation-duration: 5s;" & @CRLF & _ " animation-timing-function: linear;" & @CRLF & _ " animation-iteration-count: infinite;" & @CRLF & _ " animation-play-state: running;" & @CRLF & _ " z-index: -1;" & @CRLF & _ " }" & @CRLF & _ " " & @CRLF & _ " .bg-stars .bg-star:nth-of-type(1) {" & @CRLF & _ " left: 10%;" & @CRLF & _ " -webkit-animation-delay: 1s, 1s;" & @CRLF & _ " animation-delay: 1s, 1s;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " .bg-stars .bg-star:nth-of-type(2) {" & @CRLF & _ " left: 20%;" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "</div></body></html>(`;" & @CRLF & _ "let m;" & @CRLF & _ "" & @CRLF & _ "while ((m = regex.exec(str)) !== null) {" & @CRLF & _ " // This is necessary to avoid infinite loops with zero-width matches" & @CRLF & _ " if (m.index === regex.lastIndex) {" & @CRLF & _ " regex.lastIndex++;" & @CRLF & _ " }" & @CRLF & _ " // The result can be accessed through the `m`-variable." & @CRLF & _ " m.forEach((match, groupIndex) => {" & @CRLF & _ " console.log(`Found match, group ${groupIndex}: ${match}`);" & @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