Function indexOfIgnoreCasePos [src]
Finds needle in haystack, ignoring case, starting at start_index.
Uses Boyer-Moore-Horspool algorithm on large inputs; indexOfIgnoreCasePosLinear on small inputs.
Prototype
pub fn indexOfIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize
Parameters
haystack: []const u8
start_index: usize
needle: []const u8
Source
pub fn indexOfIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {
if (needle.len > haystack.len) return null;
if (needle.len == 0) return start_index;
if (haystack.len < 52 or needle.len <= 4)
return indexOfIgnoreCasePosLinear(haystack, start_index, needle);
var skip_table: [256]usize = undefined;
boyerMooreHorspoolPreprocessIgnoreCase(needle, skip_table[0..]);
var i: usize = start_index;
while (i <= haystack.len - needle.len) {
if (eqlIgnoreCase(haystack[i .. i + needle.len], needle)) return i;
i += skip_table[toLower(haystack[i + needle.len - 1])];
}
return null;
}