package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`01(?=\.jpg)(.*)(\d{2}).jpg`)
var str = ` <item id="P2_0102_01.jpg" href="images/01_02/P2_0102_55.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_56.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_57.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_58.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_59.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_60.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_61.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_62.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_63.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_64.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_65.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_66.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_67.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_68.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_69.jpg" media-type="image/jpeg"/>
<item id="P2_0102_01.jpg" href="images/01_02/P2_0102_70.jpg" media-type="image/jpeg"/>`
var substitution = "\2\1\2.jpg"
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/