package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?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]*)?)?)`)
var str = `| 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`
var substitution = "$1$4"
fmt.Println(re.ReplaceAllString(str, 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 Golang, please visit: https://golang.org/pkg/regexp/