// 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)https?:\/\/\S+\.[^()]+(?:\([^)]*\))*").unwrap();
let string = "https://testing.go.id/kantal-(1)(2)
(e.g. https://testing.go.id/beginilah-jika-kita-suka-haha)
https://green.kumparan.com/kantal-(1)(2)
(e.g. https://green.kumparan.com/kantal-(1)(2))
(e.g. https://green.kumparan.com/beginilah-jika-kita-suka-haha)
https://green.kumparan.com/kantal-(1)(2)
(e.g. https://green.kumparan.com/beginilah-jika-kita-suka-haha.jpg?haha=hoho&hehe$)
https://blue.kumparan.com/kantal-(1)(2)
(e.g. https://blue.kumparan.com/kantal-(1)(2))
(e.g. https://blue.kumparan.com/beginilah-jika-kita-suka-haha)
https://blue.kumparan.com/kantal-(1)(2)
(e.g. https://blue.kumparan.com/beginilah-jika-kita-suka-haha)
https://blue.kumparan.com/image/upload/f_jpg,fl_progressive,fl_lossy,c_fill,g_face,q_auto:best,w_480,ar_5:7/v1554524445/r6dxtztvmtw9by9oaibe.jpg
url(https://blue.kumparan.com/uikit-assets/assets/logos/404-653d82fd9ae91d1d6cf474e4fd929e47.png)
https://green.kumparan.com/image/upload/fl_progressive,fl_lossy,c_fill,q_auto:best,w_480,ar_5:7/v1553692790/jpgffb7pcs8yo7v0rs2y.jpg
url(https://green.kumparan.com/image/upload/fl_progressive,fl_lossy,c_fill,q_auto:best,w_640/v1554524445/r6dxtztvmtw9by9oaibe.jpg)";
// 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/