package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?U)href=(['"])(?:.*\/wp-content\/uploads\/2018\/01\/(?:(?:.*( ))+?).*\.(?:pdf|doc|docx))\1`)
var str = `<a href="/wp-content/uploads/2017/09/Some%20FileName%20That%20Wasnt%20sanitized%20at_all986.pdf">
<a title="Some title of the linked document" href="https://[redacted]/wp-content/uploads/2018/01/Some Title Thats Not Sanitized And Has Spaces 1.1.111-id1111.pdf" target="_blank" rel="noopener">Some Link Text For This</a></li>
`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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/