digitalmars.D - BoyerMooreFinder predicates / case-insensitive find
- Ralf (21/24) Nov 26 2015 It seems the BoyerMooreFinder currently cannot be customized with
It seems the BoyerMooreFinder currently cannot be customized with a mapping like toLower: import std.algorithm; import std.stdio; void main(string[] args) { writeln("> ", find("Hello World", boyerMooreFinder("World"))); writeln("> ", find("Hello World", boyerMooreFinder!("toLower(a) == toLower(b)")("world"))); writeln("> ", find("EE Hello World", boyerMooreFinder!("toLower(a) == toLower(b)")("worl"))); } Result:World WorldThe problem is here: https://github.com/D-Programming-Language/phobos/blob/v2.069.1/std/algorithm/searching.d#L280 When it looks letters up in its private lookup tables, it uses the original letters, not the lower case ones. Wouldn't it make sense to allow specifying a mapping operation via an additional parameter? (With the current API, I had to copy the algorithm class and customize it to use .toLower - works great while calling .toLower() on the whole string makes things a lot slower)
Nov 26 2015