package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)<!--\s*ID\:\s*\d+\s*-->(?=\n*-\s+)`)
var str = `### Alias
Q: what check to do before creating an alias?
A: check whether any other command exists by that name using \`type new-alias-name\`
<!--ID: 1643091253375-->
---
Q: syntax to create an alias?
A: \`alias name='string'\`
<!--ID: 1645446702965-->
- no spaces before or after the equal sign
- single quotes around the command sequence
![[Pasted image 20220125092954.png]]
<!--ID: 1643091253408-->
---
### Redirection/Piping
Q: output of \`> ls-output.txt\`
A: the file will be truncated if it exists or it would be created.
<!--ID: 1645087988730-->
- Simply using the redirection operator with no command preceding it will truncate an existing file or create a new empty file
<!--ID: 1643351731943-->
`
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/