package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)# Chunk or note time.
(?<= \| )
(?: \s+) (\() ([0-2][0-9]) (:) ([0-5][0-9]) (\))
(?= \s+ \|)
|
# Revision title.
(?<= \s \| \s)
(\(.+\s\#\d+\))
(?= \s+ \|)
|
# Chunk title.
(?<= \| \s [0-2][0-9] : [0-5][0-9] - [0-2][0-9] : [0-5][0-9] \s \| \s )
(?! \[ | \s* \| )
(?:\s*)? (.+?)
(?= \s+ \|)
|
# Chunk note.
(?<= \s \| \s ) (?! -{2} )
(- .+?)
(?= \s+ \|)`)
var str = `[^\S\n] (?:\s*\r\n|\s*\r|\s*\n)
# Time block
| Time | Block |
| ----------: | :---------------- |
| (00:00) | (Revision #1) |
| | |
| 00:00-00:00 | Chunk |
| | - Note w/ details |
| 00:00-00:00 | Some meeting |
| 11:00-13:00 | Chunk |
| 13:00 | - Note w/ details |
| | |
| (00:00) | (Revision #1) |
| 00:00-00:00 | Chunk |
| | - Note w/ details |
## Time Tracking
| Tracker | Task | Backlog |
| ----------: | :---------------------------------- | :------------ |
| 08:04-08:53 | [x] * Task for deep work block (#1) | [[wiki.link]] |
| 09:07-09:56 | | Don't match |
| 98m | | |
| | | |
| 00:00-00:00 | Can Match | |
| | Don't Match | |
| 00:00-00:00 | | Don't match |
Group 1: \`(\` for time
Group 2: \`00\` hour (for chunk)
Group 3: \`:\` (for chunk)
Group 4: \`00\` minute (for chunk)
Group 5: \`)\` for time
Group 6: \`(Revision #1)\`
Group 7: \`Chunk\`or \`Some meeting\`
Group 8: \`- Note w/ details\`
`
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/