// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r#"(?m)<div[\s\S]*?id=\"variationsTwister[\s\S]*?<span[\s\S]*?a-dropdown-container[\s\S]*?<select[\s\S]*?<\/select>[\s\S]*?Color:<\/span>[\s\S]*?<span[\s\S]*?>([\s\S]*?)<\/span>"#).unwrap();
let string = "<div id=\"variationsTwister\" class=\"a-section a-spacing-mini\">
<div class=\"a-section a-spacing-micro\">
<span class=\"a-size-base\">Size:</span>
<span class=\"a-size-base a-text-bold\"></span>
</div>
<span class=\"a-dropdown-container\"><select name=\"\" autocomplete=\"off\" data-a-native-class=\"olpTwisterDropdown\" tabindex=\"-1\" class=\"a-native-dropdown a-spacing-small olpTwisterDropdown\">
<option value=\"/gp/offer-listing/B00NNA39IE/ref=olp_twister_all?ie=UTF8&mv_color_name=3&mv_size_name=all\">
Lowest offer for each
</option>
<option value=\"/gp/offer-listing/B00MC3QSKO/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=0\">
5 M US
</option>
<option value=\"/gp/offer-listing/B00MC3QU1G/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=1\">
5.5 M US
</option>
<option value=\"/gp/offer-listing/B00MC3QX72/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=2\">
6 M US
</option>
<option value=\"/gp/offer-listing/B00MC3QYQC/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=3\">
6.5 M US
</option>
<option value=\"/gp/offer-listing/B00MC3R0PQ/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=4\">
7 M US
</option>
<option value=\"/gp/offer-listing/B00MC3R23Q/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=5\">
7.5 M US
</option>
<option value=\"/gp/offer-listing/B00MC3R3M6/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=6\" selected=\"\">
8 M US
</option>
<option value=\"/gp/offer-listing/B00MC3R6LO/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=7\">
8.5 M US
</option>
<option value=\"/gp/offer-listing/B00MC3R9IY/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=8\">
9 M US
</option>
<option value=\"/gp/offer-listing/B00MC3RBE6/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=9\">
9.5 M US
</option>
<option value=\"/gp/offer-listing/B00MC3RCPY/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=10\">
10 M US
</option>
</select><span tabindex=\"-1\" id=\"olpTwisterDropdownAUI\" class=\"a-button a-button-dropdown a-button-small a-spacing-small\" style=\"min-width: 0.583333%;\"><span class=\"a-button-inner\"><span class=\"a-button-text a-declarative\" data-action=\"a-dropdown-button\" role=\"button\" tabindex=\"0\" aria-hidden=\"true\"><span class=\"a-dropdown-prompt\">
8 M US
</span></span><i class=\"a-icon a-icon-dropdown\"></i></span></span></span>
<div class=\"a-section a-spacing-micro\">
<span class=\"a-size-base\">Color:</span>
<span class=\"a-size-base a-text-bold\">Taupe</span>
</div>
<ul class=\"a-unordered-list a-nostyle a-button-list a-declarative a-button-toggle-group a-horizontal a-spacing-small\" role=\"radiogroup\" data-action=\"a-button-group\">
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-0\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B0002MB0DM/ref=olp_twister_child?ie=UTF8&mv_color_name=0&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-0-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41jl1EwZjHL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-1\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B005BFV1DO/ref=olp_twister_child?ie=UTF8&mv_color_name=1&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-1-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41XqEgaqwtL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-2\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B00MC3SFXW/ref=olp_twister_child?ie=UTF8&mv_color_name=2&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-2-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41cNhnckTFL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-selected a-button-thumbnail a-button-toggle\" id=\"a-autoid-3\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B00MC3R3M6/ref=olp_twister_child?ie=UTF8&mv_color_name=3&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-3-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41p2f8xA8TL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-4\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B011SBR9PS/ref=olp_twister_child?ie=UTF8&mv_color_name=4&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-4-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/311Xw94d26L._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-5\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B07FYS34S4/ref=olp_twister_child?ie=UTF8&mv_color_name=5&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-5-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41r4qvtmEkL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-6\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B00MC3TVSK/ref=olp_twister_child?ie=UTF8&mv_color_name=6&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-6-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/31YEDbIcNwL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-7\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B016W1Z1RC/ref=olp_twister_child?ie=UTF8&mv_color_name=7&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-7-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41plM8TSFBL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-thumbnail a-button-toggle\" id=\"a-autoid-8\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B0007L7WPS/ref=olp_twister_child?ie=UTF8&mv_color_name=8&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-8-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41NGM8gp7hL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</a></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-disabled a-button-thumbnail a-button-toggle\" id=\"a-autoid-9\"><span class=\"a-button-inner\"><input disabled=\"disabled\" class=\"a-button-input\" type=\"submit\" aria-labelledby=\"a-autoid-9-announce\"><span class=\"a-button-text\" aria-hidden=\"true\" id=\"a-autoid-9-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41WBKxWvoLL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</span></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-disabled a-button-thumbnail a-button-toggle\" id=\"a-autoid-10\"><span class=\"a-button-inner\"><input disabled=\"disabled\" class=\"a-button-input\" type=\"submit\" aria-labelledby=\"a-autoid-10-announce\"><span class=\"a-button-text\" aria-hidden=\"true\" id=\"a-autoid-10-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41ap6ahxMRL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</span></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-disabled a-button-thumbnail a-button-toggle\" id=\"a-autoid-11\"><span class=\"a-button-inner\"><input disabled=\"disabled\" class=\"a-button-input\" type=\"submit\" aria-labelledby=\"a-autoid-11-announce\"><span class=\"a-button-text\" aria-hidden=\"true\" id=\"a-autoid-11-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/41QD5K54hPL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</span></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-disabled a-button-thumbnail a-button-toggle\" id=\"a-autoid-12\"><span class=\"a-button-inner\"><input disabled=\"disabled\" class=\"a-button-input\" type=\"submit\" aria-labelledby=\"a-autoid-12-announce\"><span class=\"a-button-text\" aria-hidden=\"true\" id=\"a-autoid-12-announce\">
<img alt=\"\" src=\"https://images-na.ssl-images-amazon.com/images/I/31qtQ78OWiL._SX35_SY35_CR,0,0,35,35_.jpg\" height=\"35\" width=\"35\">
</span></span></span>
</span></li>
<li class=\"a-spacing-mini\"><span class=\"a-list-item\">
<span class=\"a-button a-button-normal a-button-toggle\" id=\"a-autoid-13\"><span class=\"a-button-inner\"><a href=\"/gp/offer-listing/B00NNA39IE/ref=olp_twister_all?ie=UTF8&mv_color_name=all&mv_size_name=6\" class=\"a-button-text\" role=\"button\" id=\"a-autoid-13-announce\">
Lowest offer for each
</a></span></span>
</span></li>
</ul>
</div>";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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 Rust, please visit: https://docs.rs/regex/latest/regex/