Function tokenizeSequence [src]

Returns an iterator that iterates over the slices of buffer that are not the sequence in delimiter. tokenizeSequence(u8, "<>abc><>ghi", "<>") will return slices for "abc>

Prototype

pub fn tokenizeSequence(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .sequence)

Parameters

T: typebuffer: []const Tdelimiter: []const T

Example

test tokenizeSequence { var it = tokenizeSequence(u8, "a<>b<><>c><>d><", "<>"); try testing.expectEqualStrings("a", it.next().?); try testing.expectEqualStrings("b", it.peek().?); try testing.expectEqualStrings("b", it.next().?); try testing.expectEqualStrings("c>", it.next().?); try testing.expectEqualStrings("d><", it.next().?); try testing.expect(it.next() == null); try testing.expect(it.peek() == null); var it16 = tokenizeSequence( u16, std.unicode.utf8ToUtf16LeStringLiteral("a<>b<><>c><>d><"), std.unicode.utf8ToUtf16LeStringLiteral("<>"), ); try testing.expect(eql(u16, it16.next().?, std.unicode.utf8ToUtf16LeStringLiteral("a"))); try testing.expect(eql(u16, it16.next().?, std.unicode.utf8ToUtf16LeStringLiteral("b"))); try testing.expect(eql(u16, it16.next().?, std.unicode.utf8ToUtf16LeStringLiteral("c>"))); try testing.expect(eql(u16, it16.next().?, std.unicode.utf8ToUtf16LeStringLiteral("d><"))); try testing.expect(it16.next() == null); }

Source

pub fn tokenizeSequence(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .sequence) { assert(delimiter.len != 0); return .{ .index = 0, .buffer = buffer, .delimiter = delimiter, }; }