Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.c++ Subject: Re: A case insensitive substring search? Date: Tue, 28 Jun 2016 23:48:24 +0100 Organization: A noiseless patient Spider Lines: 17 Message-ID: <877fd9gcav.fsf@bsb.me.uk> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="11106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PuFkFscSqI++MopuYsPeEH8Z/VxPLkA4=" Cancel-Lock: sha1:mIPPuFfHxxn+7qZa+ZieC/GWVfc= sha1:GDk7q8xyHuuvMtP9lWcVpzVkP8s= X-BSB-Auth: 1.178ba80c17d9a32f4929.20160628234824BST.877fd9gcav.fsf@bsb.me.uk Xref: csiph.com comp.lang.c++:43583 James Moe writes: > A case insensitive substring search: How hard can it be?. > I searched for it. There are lots of case insensitive string searches, > but very few case insensitive substring searches. Nothing that I could > understand. > I came up with the following. It seemed that search_n() was perfect > for a substring search; I just had to supply an appropriate comparison > function. which is where I stalled. You need search, not search_n. And if you are using modern C++ you can pass a lambda for the comparison function so there is no need for an extra named function (though that's not a big deal). -- Ben.