Add bytes.remove, bytes.remove_all, strings.remove, strings.remove_all
This commit is contained in:
1 parent
b8f8d4c3a1
commit
e82f8214e8
2 files changed
+16
No files matched your search
@@ -526,6 +526,14 @@ replace :: proc(s, old, new: []byte, n: int, allocator := context.allocator) ->
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove :: proc(s, key: []byte, n: int, allocator := context.allocator) -> (output: []byte, was_allocation: bool) {
|
||||||
|
return replace(s, key, {}, n, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_all :: proc(s, key: []byte, allocator := context.allocator) -> (output: []byte, was_allocation: bool) {
|
||||||
|
return remove(s, key, -1, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
@(private) _ascii_space := [256]u8{'\t' = 1, '\n' = 1, '\v' = 1, '\f' = 1, '\r' = 1, ' ' = 1};
|
@(private) _ascii_space := [256]u8{'\t' = 1, '\n' = 1, '\v' = 1, '\f' = 1, '\r' = 1, ' ' = 1};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -541,6 +541,14 @@ replace :: proc(s, old, new: string, n: int, allocator := context.allocator) ->
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove :: proc(s, key: string, n: int, allocator := context.allocator) -> (output: string, was_allocation: bool) {
|
||||||
|
return replace(s, key, "", n, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_all :: proc(s, key: string, allocator := context.allocator) -> (output: string, was_allocation: bool) {
|
||||||
|
return remove(s, key, -1, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
@(private) _ascii_space := [256]u8{'\t' = 1, '\n' = 1, '\v' = 1, '\f' = 1, '\r' = 1, ' ' = 1};
|
@(private) _ascii_space := [256]u8{'\t' = 1, '\n' = 1, '\v' = 1, '\f' = 1, '\r' = 1, ' ' = 1};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user