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
No Match

r"
"
gms

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 = "(?ms)<a[\S ]*href=\"([a-zA-Z0-9\/\.:]*)\"[\S ]*[\s]*><img[\S ]*src=\"([a-zA-Z0-9\/\.]*)\"[\S ]*[\s]*\/{0,1}><\/a>" Local $sString = "<!DOCTYPE html>" & @CRLF & _ "<html lang="en">" & @CRLF & _ " <head>" & @CRLF & _ " <meta charset="utf-8" />" & @CRLF & _ " <title>maia :3</title>" & @CRLF & _ " " & @CRLF & _ " <link rel="stylesheet" href="/style.css"/>" & @CRLF & _ " <link rel="stylesheet" href="/prism.css"/>" & @CRLF & _ "" & @CRLF & _ " <meta name="description" content="meow" />" & @CRLF & _ " <meta name='keywords' content='nyancrimew,maia arson crimew,android,switzerland,hacktivism,lucerne,developer,hacktivism'>" & @CRLF & _ " <meta property="og:title" content="maia :3">" & @CRLF & _ " <meta property="og:description" content="meow">" & @CRLF & _ " <meta property="og:url" content="https://maia.crimew.gay/">" & @CRLF & _ " <meta property="og:image" content="https://maia.crimew.gay/img/cover.jpg">" & @CRLF & _ " " & @CRLF & _ " <meta property="og:site_name" content="maia :3">" & @CRLF & _ " <meta name="article:author" content="maia arson crimew">" & @CRLF & _ " <meta name="article:published_time" content="2023-01-21T17:21:09.000Z">" & @CRLF & _ " <meta name="twitter:card" content="summary_large_image">" & @CRLF & _ " <meta name="twitter:site" content="@_nyancrimew">" & @CRLF & _ " <meta name="twitter:creator" content="@_nyancrimew">" & @CRLF & _ " <meta name="theme-color" content="#eca9cb">" & @CRLF & _ " <link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">" & @CRLF & _ " <link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">" & @CRLF & _ " <link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png">" & @CRLF & _ " <link rel="shortcut icon" href="/favicon.ico">" & @CRLF & _ "" & @CRLF & _ " <link rel="alternate" type="application/rss+xml" href="/feed.xml" />" & @CRLF & _ " </head>" & @CRLF & _ " <body>" & @CRLF & _ " <header id="site_header">" & @CRLF & _ " <h1>maia <sub>arson crimew</sub></h1>" & @CRLF & _ " <nav>" & @CRLF & _ " " & @CRLF & _ " <span><a href="/" class="active">home</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="/posts/" >blog</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="/samples/" >sample packs</a></span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "</nav>" & @CRLF & _ " </header>" & @CRLF & _ " <div id="content">" & @CRLF & _ " " & @CRLF & _ "<div style="display: flex; flex-wrap: wrap; justify-content: center;">" & @CRLF & _ " <div style="flex-grow: 1; flex-shrink: 1; flex-basis: 30%; min-width: 200px; max-width: 70%;">" & @CRLF & _ " <img src="/img/kitten_cropped.png" alt="a drawing of a small white kitten with black spots sitting and looking at you">" & @CRLF & _ " </div>" & @CRLF & _ " <div style="flex-grow: 2; flex-shrink: 2; flex-basis: 60%;">" & @CRLF & _ " <p>" & @CRLF & _ " hello i am maia arson crimew <sup>(it/she)</sup> and i am gay, mostly for girls, and i'm a tiny kitten :3" & @CRLF & _ " </p>" & @CRLF & _ " <p>" & @CRLF & _ " i know lot's of things about cyber security, programming and far too little about music but i still" & @CRLF & _ " try to do all those things at once. if you like the things i do here or on social media you can" & @CRLF & _ " <a href="https://ko-fi.com/nyancrimew" target="_blank">support me on ko-fi</a>. links to the various things i do" & @CRLF & _ " can be found in the footer. if you're looking for some more serious info about me, " & @CRLF & _ " <a href="https://en.wikipedia.org/wiki/maia_arson_crimew" target="_blank">there is wikipedia for that</a>." & @CRLF & _ " </p>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " <footer>" & @CRLF & _ " <div class="footer-kitten"><img src="/img/walkingkitten_crop.png" alt="a small white kitten with black spots walking across the screen"></div>" & @CRLF & _ " <div>" & @CRLF & _ " " & @CRLF & _ " <span><a href="https://maia.crimew.gay/feed.xml" rel="me" target="_blank">rss feed</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="https://twitter.com/_nyancrimew" rel="me" target="_blank">birded site</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="https://crimew.gay/maia" rel="me" target="_blank">fedded verse</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="https://soundcloud.com/nyancrimew" rel="me" target="_blank">sounded cloud</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="https://last.fm/user/nyancrimew" rel="me" target="_blank">last dot federated states of micronesia</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="https://github.com/nyancrimew" rel="me" target="_blank">gitted hub</a></span>" & @CRLF & _ " " & @CRLF & _ " <span>|</span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span><a href="https://git.lavender.software/nyancrimew" rel="me" target="_blank">gitted tea</a></span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <div class="badges">" & @CRLF & _ " " & @CRLF & _ " <a href="https://maia.crimew.gay" target="_blank"><img src="/badges/maia.crimew.gay.png" alt="maia crimew" title="my site :3"></a>" & @CRLF & _ " " & @CRLF & _ " <a href="https://cyber.dabamos.de/88x31" target="_blank"><img src="/badges/88x31.gif" alt="88x31" title="baaaadges"></a>" & @CRLF & _ " " & @CRLF & _ " <a href="javascript:alert(&#39;what did i tell you??&#39;)" target="_blank"><img src="/badges/noclick.gif" alt="don&#39;t click here" title="don&#39;t do it"></a>" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/acab.gif" alt="acab" title="fuck the cops">" & @CRLF & _ " " & @CRLF & _ " <a href="https://archlinux.org" target="_blank"><img src="/badges/archlinux.gif" alt="arch linux" title="i use arch btw"></a>" & @CRLF & _ " " & @CRLF & _ " <a href="https://versary.town" target="_blank"><img src="/badges/versarytown.png" alt="versary town" title="a very cool website by a very cool person &lt;3"></a>" & @CRLF & _ " " & @CRLF & _ " <a href="https://goop.house" target="_blank"><img src="/badges/goop.gif" alt="goop house" title="goop house next up"></a>" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/anarchynow.gif" alt="anarchy now" >" & @CRLF & _ " " & @CRLF & _ " <a href="https://sleepy.zone" target="_blank"><img src="/badges/sleepy.png" alt="sleepy zone" title="sleepy.zone is the best internet radio out there"></a>" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/kitten88.gif" alt="kitten&#39;s corner" title="im a kitten fr fr">" & @CRLF & _ " " & @CRLF & _ " <a href="https://oat.zone" target="_blank"><img src="/badges/oatzone.gif" alt="oat.zone" ></a>" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/slimesnow.png" alt="slimes now" >" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/slugcat.png" alt="slugcat" >" & @CRLF & _ " " & @CRLF & _ " <a href="https://sinewave.cyou" target="_blank"><img src="/badges/sinewave.gif" alt="sinewave" ></a>" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/nonbinary.png" alt="non-binary pride" title="im non binary fr fr">" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/queer.png" alt="queer pride" title="im queeeer as fuck">" & @CRLF & _ " " & @CRLF & _ " <img src="/badges/piracy.gif" alt="piracy now" title="piracy is swag and you should do it">" & @CRLF & _ " " & @CRLF & _ " <a href="https://utsuho.rocks" target="_blank"><img src="/badges/utsuhorocks.png" alt="utsuho rocks" title="utsuho rocks"></a>" & @CRLF & _ " " & @CRLF & _ " <a href="https://ilwag.com" target="_blank"><img src="/badges/ilwagbannersmol.png" alt="ilwag.com" title="cute lil tunes :3"></a>" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <script src="https://lavender.software/webring/webring-0.2.0.js" data-site-id="maia"></script>" & @CRLF & _ "</footer>" & @CRLF & _ " </body>" & @CRLF & _ "</html>" & @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