// 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"(?i)(\|\s*(logo|image|screenshot|race_logo|track map)\s*=\s*)(File:|Image:)?([^\[\||<\n]*)((\|\s*\d{1,4}px(\?)?|\|\s*thumb))((\|\s*\d{1,4}px(\?)?|\|\s*thumb))?(?(?=\|[A-z]*\s*=)|(?(?=\|(\w*\W*)*)(\|[^\|\n]*)?)?)").unwrap();
let string = "| image = [[File:Central Asia (orthographic projection).svg|200px|Map of Central Asia]]
|Image=|150px?
}}]] – [[Template:POTD/2012-06-09|{{POTD texttitle
|image=Jack-in-cube solid model, light background.gif
|thumb=Jack-in-cube solid model, light background frame.png
|size=180
|name = Reggae
| Image = File:Bob-Marley.jpg|thumb|231px|
| caption = Popular reggae artist [[Bob Marley]] in 1980
{{Infobox officeholder
|image = Karenskiy AF 1917.jpg|230px
|nationality = Russian
{{Infobox officeholder
|image = Karenskiy AF 1917.jpg|230px|thumb
|nationality = Russian
{{Infobox officeholder
|image = Karenskiy AF 1917.jpg|thumb
|nationality = Russian
{{Infobox officeholder
|image = Karenskiy AF 1917.jpg|230px|nationality = Russian
|country=IND
|image= National Highway 2 (India).png|300px|Road map of India with NH 19 highlighted in solid blue color
|type=NH
|image = File:April 14, 2012 Marquette, Kansas EF4 tornado.JPG|309px
{{Infobox football club |
clubname = Slovácko |
image = Image:1FC Slovacko.png|150px|Logo |
fullname = 1. FC Slovácko A.S. |
| image = <imagemap>
File:Primates - some families.jpg|300px";
let substitution = "$1$4";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", 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 Rust, please visit: https://docs.rs/regex/latest/regex/