Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #43584

Re: A case insensitive substring search?

From Nobody <nobody@nowhere.invalid>
Newsgroups comp.lang.c++
Subject Re: A case insensitive substring search?
Date 2016-06-29 00:39 +0100
Organization A noiseless patient Spider
Message-ID <pan.2016.06.28.23.41.22.74000@nowhere.invalid> (permalink)
References <C6mdnaL0a8umRu_KnZ2dnUU7-cHNnZ2d@giganews.com>

Show all headers | View raw


On Tue, 28 Jun 2016 13:16:55 -0700, James Moe wrote:

>   A case insensitive substring search: How hard can it be?.

Substring search is provided by the std::basic_string::find() method.
Comparisons are performed using the eq() member of the traits class,
so if you use a traits class where eq() is case-insensitive, you get a
case-insensitive substring comparison.

But that requires using an explicit specialisation of std::basic_string
rather than just using std::string or std::wstring (which use
std::char_traits implicitly). A cast would almost certainly work, but
(AFAIK) it's not guaranteed.

Whatever method you choose, there's the issue that it isn't always
possible to perform a case-insensitive comparison character-by-character.

The classic example of where this fails is that the German "sharp s"
character ("ß") doesn't have an equivalent upper-case character; the
upper-case equivalent is "SS". There's no way to handle this situation
using only the standard library, where case conversion is assumed to map
one character to one character.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

A case insensitive substring search? James Moe <jimoeDESPAM@sohnen-moe.com> - 2016-06-28 13:16 -0700
  Re: A case insensitive substring search? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-28 23:48 +0100
    Re: A case insensitive substring search? James Moe <jimoeDESPAM@sohnen-moe.com> - 2016-06-28 22:25 -0700
      Re: A case insensitive substring search? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-29 10:56 +0100
        Re: A case insensitive substring search? Öö Tiib <ootiib@hot.ee> - 2016-06-29 04:19 -0700
      Re: A case insensitive substring search? James Moe <jimoeDESPAM@sohnen-moe.com> - 2016-06-29 10:48 -0700
  Re: A case insensitive substring search? Nobody <nobody@nowhere.invalid> - 2016-06-29 00:39 +0100
    Re: A case insensitive substring search? Öö Tiib <ootiib@hot.ee> - 2016-06-29 06:22 -0700
      Re: A case insensitive substring search? Ralf Goertz <me@myprovider.invalid> - 2016-06-29 17:16 +0200
        Re: A case insensitive substring search? Öö Tiib <ootiib@hot.ee> - 2016-07-01 01:46 -0700
    Re: A case insensitive substring search? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-06-29 21:32 +0200
    Re: A case insensitive substring search? Nobody <nobody@nowhere.invalid> - 2016-07-01 07:53 +0100

csiph-web