From 77568e114ff531f4fe14cfaeab6febd53a99b1bc Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:21:55 +0800 Subject: Don't trim last field when delimiter is regex (#4266) --- src/tokenizer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tokenizer.go b/src/tokenizer.go index 573a3576..edf36903 100644 --- a/src/tokenizer.go +++ b/src/tokenizer.go @@ -225,7 +225,9 @@ func StripLastDelimiter(str string, delimiter Delimiter) string { locs := delimiter.regex.FindAllStringIndex(str, -1) if len(locs) > 0 { lastLoc := locs[len(locs)-1] - str = str[:lastLoc[0]] + if lastLoc[1] == len(str) { + str = str[:lastLoc[0]] + } } } return strings.TrimRightFunc(str, unicode.IsSpace) -- cgit v1.2.3