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

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)<div\s[\s\S]*?\"detailBulletsWrapper_feature_div[\s\S]*?<div\s[\s\S]*?detailBullets_feature_div[\s\S]*?<ul[\s\S]*?ASIN:[\s\S]*?<\/span>\s*<span>([\s\S]*?)<\/span>" Local $sString = "<div id="detailBulletsWrapper_feature_div" data-feature-name="detailBullets" data-template-name="detailBullets" class="a-section a-spacing-none feature" data-cel-widget="detailBulletsWrapper_feature_div">" & @CRLF & _ " <div id="detailBullets_feature_div">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <ul class="a-unordered-list a-nostyle a-vertical a-spacing-none">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <li><span class="a-list-item">" & @CRLF & _ " " & @CRLF & _ " <span class="a-text-bold">Product Dimensions:" & @CRLF & _ " </span>" & @CRLF & _ " <span>5 x 5 x 0.7 inches</span>" & @CRLF & _ " " & @CRLF & _ " </span></li>" & @CRLF & _ " " & @CRLF & _ " <li><span class="a-list-item">" & @CRLF & _ " " & @CRLF & _ " <span class="a-text-bold">Shipping Weight:" & @CRLF & _ " </span>" & @CRLF & _ " <span>12 ounces (<a href="https://www.amazon.com/gp/help/seller/shipping.html/ref=dp_pd_shipping?_encoding=UTF8&amp;seller=&amp;asin=B07F9GS3VY">View shipping rates and policies</a>)</span>" & @CRLF & _ " " & @CRLF & _ " </span></li>" & @CRLF & _ " " & @CRLF & _ " <li><span class="a-list-item">" & @CRLF & _ " " & @CRLF & _ " <span class="a-text-bold">ASIN:" & @CRLF & _ " </span>" & @CRLF & _ " <span>B07F9GS3VY</span>" & @CRLF & _ " " & @CRLF & _ " </span></li>" & @CRLF & _ " " & @CRLF & _ " <li><span class="a-list-item">" & @CRLF & _ " " & @CRLF & _ " </span></li>" & @CRLF & _ " " & @CRLF & _ " <li><span class="a-list-item">" & @CRLF & _ " " & @CRLF & _ " <span class="a-text-bold">Item model number:" & @CRLF & _ " </span>" & @CRLF & _ " <span>WXAGLHP2</span>" & @CRLF & _ " " & @CRLF & _ " </span></li>" & @CRLF & _ " " & @CRLF & _ " <li><span class="a-list-item">" & @CRLF & _ " " & @CRLF & _ " <span class="a-text-bold">Date first listed on Amazon:" & @CRLF & _ " </span>" & @CRLF & _ " <span>September 11, 2013</span>" & @CRLF & _ " " & @CRLF & _ " </span></li>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " </ul>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<div id="dpx-amazon-sales-rank_feature_div">" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "<style type="text/css">" & @CRLF & _ ".zg_hrsr_item {list-style : none};" & @CRLF & _ "</style>" & @CRLF & _ "<li id="SalesRank" style="list-style : none">" & @CRLF & _ "<b>Amazon Best Sellers Rank:</b> #36,542 in Clothing, Shoes &amp; Jewelry (<a href="https://www.amazon.com/gp/bestsellers/fashion/ref=pd_dp_ts_fashion_1">See Top 100 in Clothing, Shoes &amp; Jewelry</a>) <style type="text/css">.zg_hrsr { margin: 0; padding: 0; list-style-type: none; }.zg_hrsr_item { margin: 0 0 0 10px; }.zg_hrsr_rank { display: inline-block; width: 80px; text-align: right; }</style><ul class="zg_hrsr"> <li class="zg_hrsr_item"> <span class="zg_hrsr_rank">#39</span> <span class="zg_hrsr_ladder">in&nbsp;<a href="https://www.amazon.com/gp/bestsellers/fashion/ref=pd_zg_hrsr_fashion_1_1">Clothing, Shoes &amp; Jewelry</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/7147440011/ref=pd_zg_hrsr_fashion_1_2">Women</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/679337011/ref=pd_zg_hrsr_fashion_1_3">Shoes</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/6127771011/ref=pd_zg_hrsr_fashion_1_4">Athletic</a> &gt; <b><a href="https://www.amazon.com/gp/bestsellers/fashion/679351011/ref=pd_zg_hrsr_fashion_1_5_last">Women's</a></b></span> </li> <li class="zg_hrsr_item"> <span class="zg_hrsr_rank">#129</span> <span class="zg_hrsr_ladder">in&nbsp;<a href="https://www.amazon.com/gp/bestsellers/fashion/ref=pd_zg_hrsr_fashion_2_1">Clothing, Shoes &amp; Jewelry</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/7147440011/ref=pd_zg_hrsr_fashion_2_2">Women</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/679337011/ref=pd_zg_hrsr_fashion_2_3">Shoes</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/6127771011/ref=pd_zg_hrsr_fashion_2_4">Athletic</a> &gt; <b><a href="https://www.amazon.com/gp/bestsellers/fashion/679377011/ref=pd_zg_hrsr_fashion_2_5_last">Walking</a></b></span> </li> <li class="zg_hrsr_item"> <span class="zg_hrsr_rank">#284</span> <span class="zg_hrsr_ladder">in&nbsp;<a href="https://www.amazon.com/gp/bestsellers/fashion/ref=pd_zg_hrsr_fashion_3_1">Clothing, Shoes &amp; Jewelry</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/7147440011/ref=pd_zg_hrsr_fashion_3_2">Women</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/679337011/ref=pd_zg_hrsr_fashion_3_3">Shoes</a> &gt; <a href="https://www.amazon.com/gp/bestsellers/fashion/6127771011/ref=pd_zg_hrsr_fashion_3_4">Athletic</a> &gt; <b><a href="https://www.amazon.com/gp/bestsellers/fashion/679360011/ref=pd_zg_hrsr_fashion_3_5_last">Women's</a></b></span> </li></ul>" & @CRLF & _ "</li>" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " <ul class="a-unordered-list a-nostyle a-vertical a-spacing-none">" & @CRLF & _ " " & @CRLF & _ " <li><span class="a-list-item">" & @CRLF & _ " <span class="a-text-bold">" & @CRLF & _ " Average Customer Review:" & @CRLF & _ " </span>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "<style type="text/css">" & @CRLF & _ " /* " & @CRLF & _ " * Fix for UDP-1061. Average customer reviews has a small extra line on hover " & @CRLF & _ " * https://omni-grok.amazon.com/xref/src/appgroup/websiteTemplates/retail/SoftlinesDetailPageAssets/udp-intl-lock/src/legacy.css?indexName=WebsiteTemplates#40" & @CRLF & _ " */" & @CRLF & _ " .noUnderline a:hover { " & @CRLF & _ " text-decoration: none; " & @CRLF & _ " }" & @CRLF & _ "</style>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " <div id="detailBullets_averageCustomerReviews" class="a-spacing-none" data-asin="B07F9GS3VY" data-ref="dpx_acr_pop_">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <span class="a-declarative" data-action="acrStarsLink-click-metrics" data-acrstarslink-click-metrics="{}">" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " <span id="acrPopover" class="reviewCountTextLinkedHistogram noUnderline" title="4.1 out of 5 stars">" & @CRLF & _ " <span class="a-declarative" data-action="a-popover" data-a-popover="{&quot;max-width&quot;:&quot;700&quot;,&quot;closeButton&quot;:&quot;false&quot;,&quot;position&quot;:&quot;triggerBottom&quot;,&quot;url&quot;:&quot;/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&amp;asin=B07F9GS3VY&quot;}">" & @CRLF & _ " <a href="javascript:void(0)" class="a-popover-trigger a-declarative">" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "<i class="a-icon a-icon-star a-star-4"><span class="a-icon-alt">4.1 out of 5 stars</span></i>" & @CRLF & _ " " & @CRLF & _ " <i class="a-icon a-icon-popover"></i></a>" & @CRLF & _ " </span>" & @CRLF & _ " <span class="a-letter-space"></span>" & @CRLF & _ " </span>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " </span>" & @CRLF & _ " <span class="a-letter-space"></span>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <span class="a-declarative" data-action="acrLink-click-metrics" data-acrlink-click-metrics="{}">" & @CRLF & _ " <a id="acrCustomerReviewLink" class="a-link-normal" href="#customerReviews">" & @CRLF & _ " <span id="acrCustomerReviewText" class="a-size-base">221 customer reviews</span>" & @CRLF & _ " </a>" & @CRLF & _ " </span>" & @CRLF & _ " " & @CRLF & _ " <script type="text/javascript">" & @CRLF & _ " P.when('A', 'ready').execute(function(A) {" & @CRLF & _ " A.declarative('acrLink-click-metrics', 'click', { "allowLinkDefault" : true }, function(event){" & @CRLF & _ " if(window.ue) {" & @CRLF & _ " ue.count("acrLinkClickCount", (ue.count("acrLinkClickCount") || 0) + 1);" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ " </script>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " <script type="text/javascript">" & @CRLF & _ " P.when('A', 'cf').execute(function(A) {" & @CRLF & _ " A.declarative('acrStarsLink-click-metrics', 'click', { "allowLinkDefault" : true }, function(event){" & @CRLF & _ " if(window.ue) {" & @CRLF & _ " ue.count("acrStarsLinkWithPopoverClickCount", (ue.count("acrStarsLinkWithPopoverClickCount") || 0) + 1);" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ " });" & @CRLF & _ " </script>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " </span></li>" & @CRLF & _ " " & @CRLF & _ " </ul>" & @CRLF & _ " <div class="a-row">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " <div class="a-row">" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " If you are a seller for this product, would you like to <b><a href="https://sellercentral.amazon.com/cu/contact-us?categoryId=30002&amp;typeId=30005">suggest updates through seller support</a></b>?" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ "</div>" 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