pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize haystack: []const u8start_index: usizeneedle: []const u8388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405pub fn findIgnoreCasePos(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 findIgnoreCasePosLinear(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;
}
Finds
needleinhaystack, ignoring case, starting atstart_index. Uses Boyer-Moore-Horspool algorithm on large inputs;findIgnoreCasePosLinearon small inputs.