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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

# coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r"\s*<div\sid=\"olpOfferList[\s\S]*?<span\sclass=\"a-size-large a-color-price olpOfferPrice a-text-bold[\s\S]*?>[\s\S]*?\s*.(.*?)\s*<\/span>" test_str = ("<div id=\"olpOfferList\" class=\"a-section olpOfferList\">\n\n\n" " <div class=\"a-section a-padding-small\">\n\n\n\n" " \n" " \n\n" " \n" " \n\n\n" " \n" " \n\n\n\n\n\n\n\n\n\n" " \n\n\n\n\n\n\n\n\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n\n\n\n\n\n" " \n\n\n\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n\n\n\n\n\n\n\n\n\n\n" " \n\n\n\n\n\n\n" " <div aria-label=\"More buying choices\" aria-readonly=\"true\" class=\"a-section a-spacing-double-large\" role=\"grid\">\n" " \n\n\n\n" "<div class=\"a-row a-spacing-mini\" role=\"row\">\n" " <div class=\"a-column a-span2\" role=\"columnheader\">\n\n" " <span class=\"a-color-secondary a-text-bold\">\n" " Price + Shipping\n" " </span>\n\n\n" " </div>\n" " <div class=\"a-column a-span3\" role=\"columnheader\">\n\n" " <span class=\"a-color-secondary a-text-bold\">\n" " Condition\n" " </span>\n\n" " \n\n\n\n\n" " (<a href=\"/gp/help/customer/display.html/ref=olp_cg_pop?ie=UTF8&amp;nodeId=200143590&amp;pop-up=1\" target=\"conditionGuidelinesFrameOLP\" onclick=\"return amz_js_PopWin('/gp/help/customer/display.html/ref=olp_cg_pop?ie=UTF8&amp;nodeId=200143590&amp;pop-up=1','conditionGuidelinesFrameOLP','width=550,height=550,resizable=1,scrollbars=1,toolbar=0,status=0');\">Learn more</a>)\n\n" " </div>\n" " <div class=\"a-column a-span3\" role=\"columnheader\">\n\n" " <span class=\"a-color-secondary a-text-bold\">\n" " Delivery\n" " </span>\n\n" " </div>\n" " <div class=\"a-column a-span2\" role=\"columnheader\">\n\n" " <span class=\"a-color-secondary a-text-bold\">\n" " Seller Information\n" " </span>\n\n" " </div>\n" " <div class=\"a-column a-span2 a-span-last\" role=\"columnheader\">\n\n" " <span class=\"a-color-secondary a-text-bold\">\n" " Buying Options\n" " </span>\n\n" " </div>\n" "</div>\n\n\n\n" " <hr class=\"a-spacing-mini a-divider-normal\">\n\n" " <div class=\"a-row a-spacing-mini olpOffer\" role=\"row\">\n" " <div class=\"a-column a-span2 olpPriceColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n" " \n" " \n\n\n\n" " \n" " \n\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n\n\n\n\n" " \n" " \n\n\n\n\n" " <span class=\"a-size-large a-color-price olpOfferPrice a-text-bold\"> $33.43 </span>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" " \n" " <span class=\"supersaver\"><i class=\"a-icon a-icon-prime\" role=\"img\" aria-label=\"Amazon Prime TM\"></i></span>\n\n\n\n\n" " <p class=\"olpShippingInfo\">\n" " <span class=\"a-color-secondary\">\n\n\n\n\n" " &amp; <b>FREE Shipping</b> <a href=\"/gp/help/customer/display.html/ref=mk_gship_olp?ie=UTF8&amp;nodeId=527692&amp;pop-up=1\" target=\"SuperSaverShipping\" onclick=\"return amz_js_PopWin('/gp/help/customer/display.html/ref=mk_gship_olp?ie=UTF8&amp;nodeId=527692&amp;pop-up=1','SuperSaverShipping','width=550,height=550,resizable=1,scrollbars=1,toolbar=0,status=0');\">Details</a>\n\n" " </span>\n" " </p>\n\n\n\n" " \n\n\n\n\n\n\n\n\n\n\n" " \n\n\n" " \n" " \n" " \n\n\n\n\n\n\n\n\n" " \n" " \n" " \n\n\n" " </div>\n" " <div class=\"a-column a-span3 olpConditionColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" " \n" " \n" " <div id=\"offerCondition\" class=\"a-section a-spacing-small\">\n" " \n\n\n\n\n" "<span id=\"olpNew\" class=\"a-size-medium olpCondition a-text-bold\">\n" " New\n" " \n" "</span>\n\n" " \n" " </div>\n\n\n" " \n\n\n\n" " \n\n\n\n\n\n\n\n" " \n\n" " </div>\n" " <div class=\"a-column a-span3 olpDeliveryColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n" " <div class=\"a-popover-preload\" id=\"a-popover-fbaPopover\">\n" " <ul id=\"popOverListHorizonte\" class=\"a-unordered-list a-vertical a-spacing-mini\">\n" " <li><span class=\"a-list-item\"> Stored, Packed &amp; Shipped by Amazon! </span></li>\n" " <li><span class=\"a-list-item\"> Eligible for Free Shipping </span></li>\n" " <li><span class=\"a-list-item\"> Amazon Customer Service 24 x 7 </span></li>\n" " <li><span class=\"a-list-item\"> Track your delivery to your door </span></li>\n" " </ul>\n" " <div id=\"olpLearnMoreLink1\" class=\"a-section a-text-right\">\n" " <a href=\"/gp/help/customer/display.html?ie=UTF8&amp;pop-up=1&amp;nodeId=106096011&amp;_ref=olp_offerlisting\" target=\"AmazonHelp\" onclick=\"return amz_js_PopWin(this.href,'AmazonHelp','width=550,height=550,resizable=1,scrollbars=1,toolbar=0,status=0');\">\n" " Learn more\n" " </a>\n" " </div>\n" " </div>\n\n" " <div id=\"olpBadgeContainerDiv1\" class=\"a-section a-spacing-none olpBadgeContainer\">\n" " <div id=\"olpBadgeDiv1\" class=\"a-section olpBadge\">\n" " <span class=\"a-declarative\" data-action=\"a-popover\" data-a-popover=\"{&quot;activate&quot;:&quot;onclick&quot;,&quot;name&quot;:&quot;fbaPopover&quot;}\" id=\"fulfilledByAmazonPopOver1\">\n" " <a id=\"fulfilledByAmazonPopOver1\" href=\"javascript:void(0)\" class=\"a-popover-trigger a-declarative olpFbaPopoverTrigger\">\n" " Fulfillment by Amazon\n" " <i class=\"a-icon a-icon-popover\"></i></a>\n" " </span>\n" " </div>\n" " </div>\n\n\n\n" " <p class=\"a-spacing-mini olpAvailability\">\n" " \n\n\n\n\n" " \n\n\n" " \n" "</p><ul class=\"a-unordered-list a-vertical olpFastTrack\">\n\n\n" " <li><span class=\"a-list-item\">\n" " \n\n\n\n\n\n\n\n\n\n\n" "<span id=\"ftm_Q%2BXEy5I26O%2FeGlS%2FJ5Ek7qkZoVXz6Ud5CNjDsS151ZC036bsKKlisesK4kKU4GPVv1BL5%2FwAI%2F4gDTEq%2F%2FIOfVMNc%2B7Lo%2B2nExrmYo8Arxn26Tv%2F%2BFui4JBuXWhn1xRVF%2F%2F8EmGEsCbiUv8%2F2EAxCA%3D%3D\">Want it delivered Monday, December 31?\n\n\n\n\n" "<span id=\"shippingMessage_ftinfo_olp_1\">Order it in the next <span id=\"ftc_Q%2BXEy5I26O%2FeGlS%2FJ5Ek7qkZoVXz6Ud5CNjDsS151ZC036bsKKlisesK4kKU4GPVv1BL5%2FwAI%2F4gDTEq%2F%2FIOfVMNc%2B7Lo%2B2nExrmYo8Arxn26Tv%2F%2BFui4JBuXWhn1xRVF%2F%2F8EmGEsCbiUv8%2F2EAxCA%3D%3D\" style=\"color: #006600;\">11 hours and 12 minutes</span>, and choose <b>Two-Day Shipping</b> at checkout.</span>\n\n\n\n\n\n\n" " <a href=\"/gp/help/customer/display.html/ref=ftinfo_olp_1?ie=UTF8&amp;nodeId=3510241&amp;pop-up=1\" target=\"_blank\" onclick=\"return amz_js_PopWin('/gp/help/customer/display.html/ref=ftinfo_olp_1?ie=UTF8&amp;nodeId=3510241&amp;pop-up=1','_blank','width=750,height=600,resizable=1,scrollbars=1,toolbar=1,status=1');\">See details</a>\n\n" "</span>\n\n" " </span></li>\n\n" " \n\n\n\n" " \n\n" " <li><span class=\"a-list-item\">\n" " <a href=\"/gp/aag/details/ref=olp_merch_ship_1?ie=UTF8&amp;asin=B00MC3R3M6&amp;seller=ATVPDKIKX0DER&amp;sshmPath=shipping-rates#aag_shipping\">Shipping rates</a>\n" " and <a href=\"/gp/aag/details/ref=olp_merch_return_1?ie=UTF8&amp;asin=B00MC3R3M6&amp;seller=ATVPDKIKX0DER&amp;sshmPath=returns#aag_returns\">return policy</a>.\n" " </span></li>\n" "</ul>\n\n\n\n\n" " <p></p>\n\n\n" " </div>\n" " <div class=\"a-column a-span2 olpSellerColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n" " \n\n\n\n\n\n\n\n\n" "<h3 class=\"a-spacing-none olpSellerName\">\n\n\n\n" " <span class=\"a-size-medium a-text-bold\"> <a href=\"/gp/aag/main/ref=olp_merch_name_1?ie=UTF8&amp;asin=B00MC3R3M6&amp;isAmazonFulfilled=1&amp;seller=A3HQTMO5D4RM39\">gbravo-com</a> </span>\n" "</h3>\n\n\n\n\n\n\n" " <p class=\"a-spacing-small\">\n" " <i class=\"a-icon a-icon-star a-star-5\"><span class=\"a-icon-alt\">5 out of 5 stars</span></i>\n" " <a href=\"/gp/aag/main/ref=olp_merch_rating_1?ie=UTF8&amp;asin=B00MC3R3M6&amp;isAmazonFulfilled=1&amp;seller=A3HQTMO5D4RM39\"><b>98% positive</b></a> over the past 12 months. (480 total ratings)\n" " <br>\n" " </p>\n\n\n\n" " \n\n\n\n\n\n" " </div>\n" " <div class=\"a-column a-span2 olpBuyColumn a-span-last\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n" " \n" " \n\n\n\n\n" "<div class=\"a-button-stack\">\n\n\n" " <form method=\"post\" action=\"/gp/item-dispatch/ref=olp_atc_new_1\" class=\"a-spacing-none\">\n" " <input type=\"hidden\" name=\"session-id\" value=\"144-9672509-5121614\">\n" " <input type=\"hidden\" name=\"qid\">\n" " <input type=\"hidden\" name=\"sr\">\n" " <input type=\"hidden\" name=\"signInToHUC\" value=\"0\" id=\"signInToHUC\">\n" " <input type=\"hidden\" name=\"metric-asin.B00MC3R3M6\" value=\"1\">\n" " <input type=\"hidden\" name=\"registryItemID.1\">\n" " <input type=\"hidden\" name=\"registryID.1\">\n" " <input type=\"hidden\" name=\"itemCount\" value=\"1\">\n" " <input type=\"hidden\" name=\"offeringID.1\" value=\"Q%2BXEy5I26O%2FeGlS%2FJ5Ek7qkZoVXz6Ud5CNjDsS151ZC036bsKKlisesK4kKU4GPVv1BL5%2FwAI%2F4gDTEq%2F%2FIOfVMNc%2B7Lo%2B2nExrmYo8Arxn26Tv%2F%2BFui4JBuXWhn1xRVF%2F%2F8EmGEsCbiUv8%2F2EAxCA%3D%3D\">\n" " <input type=\"hidden\" name=\"isAddon\" value=\"1\">\n\n\n\n" " <span class=\"a-declarative\" data-action=\"olp-click-log\" data-olp-click-log=\"{&quot;subtype&quot;:&quot;main&quot;,&quot;type&quot;:&quot;addToCart&quot;}\">\n" " <span class=\"a-button a-button-normal a-spacing-micro a-button-primary a-button-icon\" id=\"a-autoid-13\"><span class=\"a-button-inner\"><i class=\"a-icon a-icon-cart\"></i><input name=\"submit.addToCart\" class=\"a-button-input\" type=\"submit\" value=\"Add to cart\" aria-labelledby=\"a-autoid-13-announce\"><span class=\"a-button-text\" aria-hidden=\"true\" id=\"a-autoid-13-announce\">\n" " Add to cart\n" " <span class=\"a-offscreen\" \"=\"\">from seller gbravo-com and price $33.43</span>\n" " </span></span></span>\n" " </span>\n\n\n\n" " </form>\n\n\n\n\n" "</div>\n\n\n\n\n" " </div>\n" " </div>\n\n\n\n\n" " <hr class=\"a-spacing-mini a-divider-normal\">\n\n" " <div class=\"a-row a-spacing-mini olpOffer\" role=\"row\">\n" " <div class=\"a-column a-span2 olpPriceColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n" " \n" " \n\n\n\n" " \n" " \n\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n\n\n\n\n" " <span class=\"a-size-large a-color-price olpOfferPrice a-text-bold\"> $73.27 </span>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" " <p class=\"olpShippingInfo\">\n" " <span class=\"a-color-secondary\">\n\n\n\n\n" " &amp; <b>FREE Shipping</b>\n\n" " </span>\n" " </p>\n\n\n\n" " \n\n\n\n\n\n\n\n\n\n\n" " \n\n\n" " \n\n\n" " </div>\n" " <div class=\"a-column a-span3 olpConditionColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n\n\n" " \n" " \n" " <div id=\"offerCondition\" class=\"a-section a-spacing-small\">\n" " \n\n\n\n\n" "<span id=\"olpNew\" class=\"a-size-medium olpCondition a-text-bold\">\n" " New\n" " \n" "</span>\n\n" " \n" " </div>\n\n\n" " \n\n\n\n" " \n\n\n\n\n\n\n\n" " \n\n" " </div>\n" " <div class=\"a-column a-span3 olpDeliveryColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n" " \n\n\n" " <p class=\"a-spacing-mini olpAvailability\">\n" " \n\n\n\n\n" " \n\n\n" " \n" "</p><ul class=\"a-unordered-list a-vertical olpFastTrack\">\n" " <li><span class=\"a-list-item\">\n" " <div aria-live=\"polite\" data-a-expander-collapsed-height=\"60\" class=\"a-expander-collapsed-height a-row a-expander-container a-spacing-base a-expander-partial-collapse-container olpAvailabilityExpander\" style=\"max-height:60px; _height:60px\">\n" " <div aria-expanded=\"false\" class=\"a-expander-content a-expander-partial-collapse-content\">\n" " <b>Arrives between</b> January 11-22.\n" " </div>\n" " <div class=\"a-expander-header a-expander-partial-collapse-header\" style=\"opacity: 0; display: none;\"><div class=\"a-expander-content-fade\"></div><a href=\"javascript:void(0)\" data-action=\"a-expander-toggle\" class=\"a-declarative\" data-a-expander-toggle=\"{&quot;allowLinkDefault&quot;:true, &quot;expand_prompt&quot;:&quot;Read more&quot;, &quot;collapse_prompt&quot;:&quot;Show less&quot;}\"><i class=\"a-icon a-icon-extender-expand\"></i><span class=\"a-expander-prompt\">Read more\n" " </span></a></div>\n" " </div>\n" " </span></li>\n\n\n\n" " \n\n\n\n" " \n\n\n\n\n" " <li><span class=\"a-list-item\">\n" " Ships from LA, United States.\n" " </span></li>\n" " <li><span class=\"a-list-item\">\n" " <a href=\"/gp/aag/details/ref=olp_merch_ship_2?ie=UTF8&amp;asin=B00MC3R3M6&amp;seller=A30PTS3CAUXNFU&amp;sshmPath=shipping-rates#aag_shipping\">Shipping rates</a>\n" " and <a href=\"/gp/aag/details/ref=olp_merch_return_2?ie=UTF8&amp;asin=B00MC3R3M6&amp;seller=A30PTS3CAUXNFU&amp;sshmPath=returns#aag_returns\">return policy</a>.\n" " </span></li>\n" "</ul>\n\n\n\n\n" " <p></p>\n\n\n" " </div>\n" " <div class=\"a-column a-span2 olpSellerColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" "<h3 class=\"a-spacing-none olpSellerName\">\n\n\n\n" " <span class=\"a-size-medium a-text-bold\"> <a href=\"/gp/aag/main/ref=olp_merch_name_2?ie=UTF8&amp;asin=B00MC3R3M6&amp;isAmazonFulfilled=0&amp;seller=A30PTS3CAUXNFU\">Top Notch iDeals</a> </span>\n" "</h3>\n\n\n\n\n\n\n" " <p class=\"a-spacing-small\">\n" " <i class=\"a-icon a-icon-star a-star-5\"><span class=\"a-icon-alt\">5 out of 5 stars</span></i>\n" " <a href=\"/gp/aag/main/ref=olp_merch_rating_2?ie=UTF8&amp;asin=B00MC3R3M6&amp;isAmazonFulfilled=0&amp;seller=A30PTS3CAUXNFU\"><b>100% positive</b></a> over the past 12 months. (113 total ratings)\n" " <br>\n" " </p>\n\n\n\n" " \n\n\n\n\n\n" " </div>\n" " <div class=\"a-column a-span2 olpBuyColumn a-span-last\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n" " \n" " \n\n\n\n\n" "<div class=\"a-button-stack\">\n\n\n" " <form method=\"post\" action=\"/gp/item-dispatch/ref=olp_atc_new_2\" class=\"a-spacing-none\">\n" " <input type=\"hidden\" name=\"session-id\" value=\"144-9672509-5121614\">\n" " <input type=\"hidden\" name=\"qid\">\n" " <input type=\"hidden\" name=\"sr\">\n" " <input type=\"hidden\" name=\"signInToHUC\" value=\"0\" id=\"signInToHUC\">\n" " <input type=\"hidden\" name=\"metric-asin.B00MC3R3M6\" value=\"1\">\n" " <input type=\"hidden\" name=\"registryItemID.1\">\n" " <input type=\"hidden\" name=\"registryID.1\">\n" " <input type=\"hidden\" name=\"itemCount\" value=\"1\">\n" " <input type=\"hidden\" name=\"offeringID.1\" value=\"Q%2BXEy5I26O%2FeGlS%2FJ5Ek7qkZoVXz6Ud5Tay9YzLDldgNMR1SZrrtV%2BtQgSXCw3lp%2FU8wErFBO8P8OJ1cwEDOkW2f3XZV0ej09NhlQ%2Fhmb0dRgKUv9LHZs5eFlyyzBIH6nT%2Fue8I74clrbWaTgsHGrHa0O4Fkl7ly\">\n" " <input type=\"hidden\" name=\"isAddon\" value=\"1\">\n\n\n\n" " <span class=\"a-declarative\" data-action=\"olp-click-log\" data-olp-click-log=\"{&quot;subtype&quot;:&quot;main&quot;,&quot;type&quot;:&quot;addToCart&quot;}\">\n" " <span class=\"a-button a-button-normal a-spacing-micro a-button-primary a-button-icon\" id=\"a-autoid-14\"><span class=\"a-button-inner\"><i class=\"a-icon a-icon-cart\"></i><input name=\"submit.addToCart\" class=\"a-button-input\" type=\"submit\" value=\"Add to cart\" aria-labelledby=\"a-autoid-14-announce\"><span class=\"a-button-text\" aria-hidden=\"true\" id=\"a-autoid-14-announce\">\n" " Add to cart\n" " <span class=\"a-offscreen\" \"=\"\">from seller Top Notch iDeals and price $73.27</span>\n" " </span></span></span>\n" " </span>\n\n\n\n" " </form>\n\n\n\n\n" "</div>\n\n\n\n\n" " </div>\n" " </div>\n\n\n\n\n" " <hr class=\"a-spacing-mini a-divider-normal\">\n\n" " <div class=\"a-row a-spacing-mini olpOffer\" role=\"row\">\n" " <div class=\"a-column a-span2 olpPriceColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n" " \n" " \n\n\n\n" " \n" " \n\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n\n\n\n\n" " <span class=\"a-size-large a-color-price olpOfferPrice a-text-bold\"> $121.00 </span>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" " <p class=\"olpShippingInfo\">\n" " <span class=\"a-color-secondary\">\n\n\n\n\n" " &amp; <b>FREE Shipping</b>\n\n" " </span>\n" " </p>\n\n\n\n" " \n\n\n\n\n\n\n\n\n\n\n" " \n\n\n" " \n\n\n" " </div>\n" " <div class=\"a-column a-span3 olpConditionColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n\n\n" " \n" " \n" " <div id=\"offerCondition\" class=\"a-section a-spacing-small\">\n" " \n\n\n\n\n" "<span id=\"olpNew\" class=\"a-size-medium olpCondition a-text-bold\">\n" " New\n" " \n" "</span>\n\n" " \n" " </div>\n\n\n" " \n\n\n\n" " \n\n\n\n\n\n\n\n" " \n\n" " </div>\n" " <div class=\"a-column a-span3 olpDeliveryColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n" " \n\n\n" " <p class=\"a-spacing-mini olpAvailability\">\n" " \n\n\n\n\n" " \n\n\n" " \n" "</p><ul class=\"a-unordered-list a-vertical olpFastTrack\">\n" " <li><span class=\"a-list-item\">\n" " <div aria-live=\"polite\" data-a-expander-collapsed-height=\"60\" class=\"a-expander-collapsed-height a-row a-expander-container a-spacing-base a-expander-partial-collapse-container olpAvailabilityExpander\" style=\"max-height:60px; _height:60px\">\n" " <div aria-expanded=\"false\" class=\"a-expander-content a-expander-partial-collapse-content\">\n" " <b>Arrives between</b> January 7-10.\n" " </div>\n" " <div class=\"a-expander-header a-expander-partial-collapse-header\" style=\"opacity: 0; display: none;\"><div class=\"a-expander-content-fade\"></div><a href=\"javascript:void(0)\" data-action=\"a-expander-toggle\" class=\"a-declarative\" data-a-expander-toggle=\"{&quot;allowLinkDefault&quot;:true, &quot;expand_prompt&quot;:&quot;Read more&quot;, &quot;collapse_prompt&quot;:&quot;Show less&quot;}\"><i class=\"a-icon a-icon-extender-expand\"></i><span class=\"a-expander-prompt\">Read more\n" " </span></a></div>\n" " </div>\n" " </span></li>\n\n\n\n" " \n\n\n\n" " \n\n" " <li><span class=\"a-list-item\">\n" " Ships from CA, United States.\n" " </span></li>\n" " <li><span class=\"a-list-item\">\n" " <a href=\"/gp/aag/details/ref=olp_merch_ship_3?ie=UTF8&amp;asin=B00MC3R3M6&amp;seller=A11M9NVQAFQWJR&amp;sshmPath=shipping-rates#aag_shipping\">Shipping rates</a>\n" " and <a href=\"/gp/aag/details/ref=olp_merch_return_3?ie=UTF8&amp;asin=B00MC3R3M6&amp;seller=A11M9NVQAFQWJR&amp;sshmPath=returns#aag_returns\">return policy</a>.\n" " </span></li>\n" "</ul>\n\n\n\n\n" " <p></p>\n\n\n" " </div>\n" " <div class=\"a-column a-span2 olpSellerColumn\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" "<h3 class=\"a-spacing-none olpSellerName\">\n\n\n\n" " <span class=\"a-size-medium a-text-bold\"> <a href=\"/gp/aag/main/ref=olp_merch_name_3?ie=UTF8&amp;asin=B00MC3R3M6&amp;isAmazonFulfilled=0&amp;seller=A11M9NVQAFQWJR\">MARCAS Brands.</a> </span>\n" "</h3>\n\n\n\n\n\n\n" " <p class=\"a-spacing-small\">\n" " <i class=\"a-icon a-icon-star a-star-4-5\"><span class=\"a-icon-alt\">4.5 out of 5 stars</span></i>\n" " <a href=\"/gp/aag/main/ref=olp_merch_rating_3?ie=UTF8&amp;asin=B00MC3R3M6&amp;isAmazonFulfilled=0&amp;seller=A11M9NVQAFQWJR\"><b>89% positive</b></a> over the past 12 months. (342 total ratings)\n" " <br>\n" " </p>\n\n\n\n" " \n\n\n\n\n\n" " </div>\n" " <div class=\"a-column a-span2 olpBuyColumn a-span-last\" role=\"gridcell\">\n" " \n\n\n\n\n\n\n\n\n" " \n" " \n\n\n\n\n" "<div class=\"a-button-stack\">\n\n\n" " <form method=\"post\" action=\"/gp/item-dispatch/ref=olp_atc_new_3\" class=\"a-spacing-none\">\n" " <input type=\"hidden\" name=\"session-id\" value=\"144-9672509-5121614\">\n" " <input type=\"hidden\" name=\"qid\">\n" " <input type=\"hidden\" name=\"sr\">\n" " <input type=\"hidden\" name=\"signInToHUC\" value=\"0\" id=\"signInToHUC\">\n" " <input type=\"hidden\" name=\"metric-asin.B00MC3R3M6\" value=\"1\">\n" " <input type=\"hidden\" name=\"registryItemID.1\">\n" " <input type=\"hidden\" name=\"registryID.1\">\n" " <input type=\"hidden\" name=\"itemCount\" value=\"1\">\n" " <input type=\"hidden\" name=\"offeringID.1\" value=\"Q%2BXEy5I26O%2FeGlS%2FJ5Ek7qkZoVXz6Ud5DtE7fw93Cz0q%2B2cCabCQ9arlcZUKqQeF3s5FmkyD23D8m%2FW1QCS6S2lqLg9w0Uw3%2FFheA9ELY7VWCZJRhASKtt09rsNqXk%2B3YPv5IaP7YzJjkmqfm7uEASExnw8zM60F\">\n" " <input type=\"hidden\" name=\"isAddon\" value=\"1\">\n\n\n\n" " <span class=\"a-declarative\" data-action=\"olp-click-log\" data-olp-click-log=\"{&quot;subtype&quot;:&quot;main&quot;,&quot;type&quot;:&quot;addToCart&quot;}\">\n" " <span class=\"a-button a-button-normal a-spacing-micro a-button-primary a-button-icon\" id=\"a-autoid-15\"><span class=\"a-button-inner\"><i class=\"a-icon a-icon-cart\"></i><input name=\"submit.addToCart\" class=\"a-button-input\" type=\"submit\" value=\"Add to cart\" aria-labelledby=\"a-autoid-15-announce\"><span class=\"a-button-text\" aria-hidden=\"true\" id=\"a-autoid-15-announce\">\n" " Add to cart\n" " <span class=\"a-offscreen\" \"=\"\">from seller MARCAS Brands. and price $121.00</span>\n" " </span></span></span>\n" " </span>\n\n\n\n" " </form>\n\n\n\n\n" "</div>\n\n\n\n\n" " </div>\n" " </div>\n\n\n\n\n\n\n" " <script> if (typeof uet == 'function') { uet('cf'); } </script> \n\n" " \n\n\n" "<script language=\"Javascript1.2\" type=\"text/javascript\">\n" " <!--\n" " var g_ftTSH = new Object();\n" " var g_ftSLH = new Object();\n" " g_ftSLH['Q%2BXEy5I26O%2FeGlS%2FJ5Ek7qkZoVXz6Ud5CNjDsS151ZC036bsKKlisesK4kKU4GPVv1BL5%2FwAI%2F4gDTEq%2F%2FIOfVMNc%2B7Lo%2B2nExrmYo8Arxn26Tv%2F%2BFui4JBuXWhn1xRVF%2F%2F8EmGEsCbiUv8%2F2EAxCA%3D%3D'] = 40370;\n\n\n\n\n\n\n" "function getTimeRemainingString( hours, minutes ) \n" "{\n" " var hourString = ( hours == 1 ? \"hour\" : \"hours\" );\n" " var minuteString = ( minutes == 1 ? \"minute\" : \"minutes\" );\n\n" " return hours + \" \" + hourString + \" and \" + minutes + \" \" + minuteString;\n" "}\n\n\n\n\n" " var FT_currentTime = new Date();\n" " var FT_currentTimeInSecs = FT_currentTime.getHours() * 3600 + FT_currentTime.getMinutes() * 60 + FT_currentTime.getSeconds();\n" " for (var i in g_ftSLH) {\n" " g_ftTSH[i] = g_ftSLH[i] + FT_currentTimeInSecs;\n" " }\n" " FT_displayCountdown();\n\n" " function FT_displayCountdown() {\n" " if (!document.layers && !document.all && !document.getElementById) {\n" " return;\n" " }\n\n" " var FT_newCurrentTime = new Date();\n" " var FT_actualSeconds = FT_newCurrentTime.getHours() * 3600 + FT_newCurrentTime.getMinutes() * 60 + FT_newCurrentTime.getSeconds();\n" " for (var i in g_ftTSH) {\n" " var FT_remainSeconds = g_ftTSH[i] - FT_actualSeconds;\n\n" " if (FT_remainSeconds < 1) {\n" " if (document.getElementById(\"ftm_\"+i)) {\n" " document.getElementById(\"ftm_\"+i).style.display = \"none\";\n" " }\n" " } else {\n" " var FT_secondsPerDay = 86400;\n" " var FT_daysLong = FT_remainSeconds / FT_secondsPerDay;\n" " var FT_days = Math.floor(FT_daysLong);\n" " var FT_hoursLong = (FT_daysLong - FT_days) * 24;\n" " var FT_hours = Math.floor(FT_hoursLong);\n" " var FT_minsLong = (FT_hoursLong - FT_hours) * 60;\n" " var FT_mins = Math.floor(FT_minsLong);\n" " var FT_secsLong = (FT_minsLong - FT_mins) * 60;\n" " var FT_secs = Math.floor(FT_secsLong);\n\n" " if (FT_days > 0) {\n" " FT_hours = (FT_days * 24) + FT_hours;\n" " }\n\n" " var ftCountdown = getTimeRemainingString( FT_hours, FT_mins );\n\n" " if (document.getElementById(\"ftc_\"+i)) {\n" " document.getElementById(\"ftc_\"+i).innerHTML = ftCountdown;\n" " }\n" " }\n" " }\n" " window.setTimeout(\"FT_displayCountdown()\", 60000);\n" " }\n" " //-->\n" "</script>\n\n\n\n" " </div>\n\n" " <input type=\"hidden\" name=\"\" value=\"/gp/offer-listing/B00MC3R3M6/ref=olp_glow_refresh?ie=UTF8&amp;f_all=true\" id=\"globalLocationWidgetRefreshUrl\">\n\n" " </div>\n" " </div>") matches = re.finditer(regex, test_str, re.MULTILINE) for matchNum, match in enumerate(matches, start=1): print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) # Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.

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 Python, please visit: https://docs.python.org/3/library/re.html