// 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?:\/\/)?(www.)?((player.vimeo.com\/video\/[0-9]{9})|((youtube.com|youtu\.be)\/embed\/([\w-]{9,11})))").unwrap();
let string = "http://www.youtube.com/watch?v=GKnQGP67Xd0
https://www.youtube.com/watch?v=GKnQGP67Xd0
https://www.youtube.com/watch?v=GKnQGP67Xd0
https://www.youtube.com/watch?v=GKnQGP67Xd0
https://vimeo.com/662065137
https://vimeo.com/662065137
https://www.youtube.com/c/riotgamesmusic
https://vimeo.com/662065137
https://youtu.be/aXUCHNaZkWo
https://vimeo.com/662065137
https://vimeo.com/baconbaconbacon
https://www.youtube.com/channel/UCG_wKjFPEpdHf1Q6bTdE2JA
https://player.vimeo.com/video/662065137
última formato corto: http://youtu.be/NLqAF9hrVbY
iframe: http://www.youtube.com/embed/NLqAF9hrVbY
iframe (seguro): https://www.youtube.com/embed/NLqAF9hrVbY
objeto param: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
objeto de incrustación: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
ver: http://www.youtube.com/watch?v=NLqAF9hrVbY
usuarios: http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo
ytscreeningroom: http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I
cualquier cosa vale!: http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/2/PPS-8DMrAn4
cualquier/subdominio/: http://gdata.youtube.com/feeds/api/videos/NLqAF9hrVbY
más params: http://www.youtube.com/watch?v=spDj54kf-vY&feature=g-vrec
la consulta puede tener el punto: http://www.youtube.com/watch?v=spDj54kf-vY&feature=youtu.be";
// 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/