BoyerMooreFinder predicates / case-insensitive find

Ralf via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 26 02:09:51 PST 2015


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
> World
> 

The 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)


More information about the Digitalmars-d mailing list