Case-Insensitive Searching

Now we're ready to discuss the first regular member function in the xstring class: find_nocase. We need this function to determine whether a given xstring contains a particular sequence of characters. For example, if we have an xstring containing the value “red, blue, and green”, describing the colors of a sofa, we want to be able to determine whether the letters “b”, “l”, “u”, and “e” appear consecutively in that string. If they do, it is sometimes also useful to know where that sequence of characters starts in the xstring.

Susan wanted to know why we would need to know where a sequence of characters was found in a string:

Susan: I understand why we need to know if we can find some characters in a string, but why would ...

Get C++: A Dialog Programming with the C++ Standard Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.