diff options
Diffstat (limited to 'src/pattern.go')
| -rw-r--r-- | src/pattern.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/pattern.go b/src/pattern.go index 93640cb6..8e6966c3 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -432,8 +432,13 @@ func (p *Pattern) transformInput(item *Item) []Token { tokens := Tokenize(item.text.ToString(), p.delimiter) ret := Transform(tokens, p.nth) - // TODO: We could apply StripLastDelimiter to exclude the last delimiter from - // the search allowing suffix match with a string or a regex delimiter. + // Strip the last delimiter to allow suffix match + if len(ret) > 0 && !p.delimiter.IsAwk() { + chars := ret[len(ret)-1].text + stripped := StripLastDelimiter(chars.ToString(), p.delimiter) + newChars := util.ToChars(stringBytes(stripped)) + ret[len(ret)-1].text = &newChars + } item.transformed = &transformed{p.revision, ret} return ret } |
