package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^[ \t]*$`)
var str = `This is the
first sentence.
This is a really long sentence
and it just keeps going across many
rows there will not necessarily be
punctuation
or consistency in word length
the only difference in ending sentence
is the next row will be blank
here would be the third sentence
as
you see
the blanks between rows of data
help define what a sentence is
this would be sentence 4
i want to pull data
from text file
as such (in sentences)
where sentences are defined with
blank records in between
this would be sentence 5 since blank row above it
and continues but ends because blank row(s) below it`
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/