// Newline after every match - only if -o is enabled and -v is disabled.
// Newline after every match - only if -o is enabled and -v is disabled.
if*onlyFlag&&!(*invertFlag){
if*onlyFlag&&!(*invertFlag){
for_,idx:=rangematchIndices{
formatchIdxNum,idx:=rangematchIndices{
ifmatchIdxNum<len(matchIndices)-1{// Only print a newline afte printing a match, if there are multiple matches on the line, and we aren't on the last one. This is because the newline that gets added at the end will take care of that.
ifi+1==idx[0].EndIdx{// End index is one more than last index of match
ifi+1==idx[0].EndIdx{// End index is one more than last index of match
fmt.Fprintf(out,"\n")
fmt.Fprintf(out,"\n")
break
break
}
}
}
}
}
}
}
}else{
}else{
if!(*onlyFlag){
if!(*onlyFlag){
fmt.Fprintf(out,"%c",c)
fmt.Fprintf(out,"%c",c)
@ -222,6 +224,10 @@ func main() {
iferr!=nil{
iferr!=nil{
panic(err)
panic(err)
}
}
// If the last character in the string wasn't a newline, AND we either have don't -o set or we do (and we've matched something), then print a newline