Back to Lo

Core Trimprefix

docs/data/core-trimprefix.md

1.53.0298 B
Original Source

Removes all leading occurrences of the given prefix from the collection.

go
result := lo.TrimPrefix([]int{1, 2, 1, 2, 3, 1, 2, 4}, []int{1, 2})
// []int{3, 1, 2, 4}

result = lo.TrimPrefix([]string{"hello", "world", "hello", "test"}, []string{"hello"})
// []string{"world", "hello", "test"}