Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Substitution
Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?s).*?<li.*?<a href="(\/release[^"]+)">([^<]+)<\/a>.*?<\/li>" Local $sString = " <li class="bucket-item ec-item horz-release" data-ec-position="87"" & @CRLF & _ " data-ec-type="product"" & @CRLF & _ " data-ec-name="Perfect Storm"" & @CRLF & _ " data-ec-creative="Label - Releases"" & @CRLF & _ " data-ec-brand="Interplay Global"" & @CRLF & _ " data-ec-category="Releases"" & @CRLF & _ " data-ec-list="Label - Releases"" & @CRLF & _ " data-ec-price="1.29"" & @CRLF & _ " data-ec-d1="David Deere, Brandon Mignacca">" & @CRLF & _ " <div class="horz-release-artwork-parent">" & @CRLF & _ " <a href="/release/perfect-storm/3265557">" & @CRLF & _ " <img class="horz-release-artwork lazy-load" src="https://geo-pro.beatport.com/static/60b2f914842e8b09024754e8a6493b36.png" data-src="https://geo-media.beatport.com/image_size/250x250/cd9e7e36-d598-45c2-a05c-d2e286a0bcb1.jpg" />" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="horz-release-meta-parent">" & @CRLF & _ " <div class="horz-release-meta">" & @CRLF & _ " " & @CRLF & _ " <p class="buk-horz-release-title"><a href="/release/perfect-storm/3265557">Perfect Storm</a></p>" & @CRLF & _ " <p class="buk-horz-release-artists">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <a href="/artist/david-deere/31534" data-artist="31534">David Deere</a>, " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <a href="/artist/brandon-mignacca/523042" data-artist="523042">Brandon Mignacca</a>" & @CRLF & _ " " & @CRLF & _ " </p>" & @CRLF & _ " <p class="buk-horz-release-labels">" & @CRLF & _ " <a href="/label/interplay-global/93385" data-label="93385">Interplay Global</a></p>" & @CRLF & _ " <p class="buk-horz-release-released">2021-02-12</p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="horz-release-actions-parent">" & @CRLF & _ " <div class="horz-release-actions">" & @CRLF & _ " <div class="horz-release-play-queue">" & @CRLF & _ " " & @CRLF & _ " <button class="playable-play" data-type="release" data-id="3265557" data-track="14824920">" & @CRLF & _ " <svg viewBox="0 0 200 200" class="play-icon">" & @CRLF & _ " <use xlink:href="/static/4fef40cebd6b915bcbe9695d5d543a01.svg#icon-play"></use>" & @CRLF & _ " </svg>" & @CRLF & _ " </button>" & @CRLF & _ " <button class="playable-queue tooltip-secondary" data-type="release" data-id="3265557" data-track="14824920">" & @CRLF & _ " <svg viewBox="0 0 16 11" class="queue-icon">" & @CRLF & _ " <use xlink:href="/static/4fef40cebd6b915bcbe9695d5d543a01.svg#icon-add-queue"></use>" & @CRLF & _ " </svg>" & @CRLF & _ " <span class="tooltiptext">Add to queue</span>" & @CRLF & _ " </button>" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " <div class="buy-button horz-release-buy-button " & @CRLF & _ "" data-release="3265557" data-price="$1.29" >" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <button class="add-to-default">$1.29</button>" & @CRLF & _ " <button class="launch-menu">" & @CRLF & _ " <div class="launch-menu-icon">" & @CRLF & _ " <svg viewBox="0 0 200 200" class="icon">" & @CRLF & _ " <use xlink:href="/static/4fef40cebd6b915bcbe9695d5d543a01.svg#icon-chevron-down"></use>" & @CRLF & _ " </svg>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="loading-menu-icon">" & @CRLF & _ " <div class="icon"></div>" & @CRLF & _ " </div>" & @CRLF & _ " </button>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <a href="#" class="icon icon-ellipsis horz-release-ellipsis mobile-action"></a>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </li>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <li class="bucket-item ec-item horz-release" data-ec-position="88"" & @CRLF & _ " data-ec-type="product"" & @CRLF & _ " data-ec-name="Glasshouse"" & @CRLF & _ " data-ec-creative="Label - Releases"" & @CRLF & _ " data-ec-brand="Interplay Global"" & @CRLF & _ " data-ec-category="Releases"" & @CRLF & _ " data-ec-list="Label - Releases"" & @CRLF & _ " data-ec-price="1.29"" & @CRLF & _ " data-ec-variant="album"" & @CRLF & _ " data-ec-id="3265543"" & @CRLF & _ " " & @CRLF & _ " data-ec-d1="Hiski, Milad E">" & @CRLF & _ " <div class="horz-release-artwork-parent">" & @CRLF & _ " <a href="/release/glasshouse/3265543">" & @CRLF & _ " <img class="horz-release-artwork lazy-load" src="https://geo-pro.beatport.com/static/60b2f914842e8b09024754e8a6493b36.png" data-src="https://geo-media.beatport.com/image_size/250x250/d45916cd-e96a-4669-9cd1-d71b28c21258.jpg" />" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="horz-release-meta-parent">" & @CRLF & _ " <div class="horz-release-meta">" & @CRLF & _ " " & @CRLF & _ " <p class="buk-horz-release-title"><a href="/release/glasshouse/3265543">Glasshouse</a></p>" & @CRLF & _ " <p class="buk-horz-release-artists">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <a href="/artist/hiski/574515" data-artist="574515">Hiski</a>, " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <a href="/artist/milad-e/581122" data-artist="581122">Milad E</a>" & @CRLF & _ " " & @CRLF & _ " </p>" & @CRLF & _ " <p class="buk-horz-release-labels">" & @CRLF & _ " <a href="/label/interplay-global/93385" data-label="93385">Interplay Global</a></p>" & @CRLF & _ " <p class="buk-horz-release-released">2021-02-05</p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="horz-release-actions-parent">" & @CRLF & _ " <div class="horz-release-actions">" & @CRLF & _ " <div class="horz-release-play-queue">" & @CRLF & _ " " & @CRLF & _ " <button class="playable-play" data-type="release" data-id="3265543" data-track="14824888">" & @CRLF & _ " <svg viewBox="0 0 200 200" class="play-icon">" & @CRLF & _ " <use xlink:href="/static/4fef40cebd6b915bcbe9695d5d543a01.svg#icon-play"></use>" & @CRLF & _ " </svg>" & @CRLF & _ " </button>" & @CRLF & _ " <button class="playable-queue tooltip-secondary" data-type="release" data-id="3265543" data-track="14824888">" & @CRLF & _ " <svg viewBox="0 0 16 11" class="queue-icon">" & @CRLF & _ " <use xlink:href="/static/4fef40cebd6b915bcbe9695d5d543a01.svg#icon-add-queue"></use>" & @CRLF & _ " </svg>" & @CRLF & _ " <span class="tooltiptext">Add to queue</span>" & @CRLF & _ " </button>" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " <div class="buy-button horz-release-buy-button " & @CRLF & _ "" data-release="3265543" data-price="$1.29" >" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <button class="add-to-default">$1.29</button>" & @CRLF & _ " <button class="launch-menu">" & @CRLF & _ " <div class="launch-menu-icon">" & @CRLF & _ " <svg viewBox="0 0 200 200" class="icon">" & @CRLF & _ " <use xlink:href="/static/4fef40cebd6b915bcbe9695d5d543a01.svg#icon-chevron-down"></use>" & @CRLF & _ " </svg>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="loading-menu-icon">" & @CRLF & _ " <div class="icon"></div>" & @CRLF & _ " </div>" & @CRLF & _ " </button>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <a href="#" class="icon icon-ellipsis horz-release-ellipsis mobile-action"></a>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </li>" Local $sSubst = "$2 https://www.beatport.com$1\n" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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