find_first_not_of

Syntax:

    #include <string>
    size_type find_first_not_of( const string& str, size_type index = 0 );
    size_type find_first_not_of( const char* str, size_type index = 0 );
    size_type find_first_not_of( const char* str, size_type index, size_type
  num );
    size_type find_first_not_of( char ch, size_type index = 0 );

The find_first_not_of() function either:

* returns the index of the first character within the current string that does

  not match any character in str, beginning the search at index, string::npos
  if nothing is found,
  not match the first num characters in str, returning the index in the current
  string of the first character found that meets this criteria, otherwise
  returning string::npos,
  match ch in the current string, starting the search at index, string::npos if
  nothing is found.

For example, the following code searches a string of text for the first character that is not a lower-case character, space, comma, or hypen:

    string lower_case = "abcdefghijklmnopqrstuvwxyz ,-";
    string str = "this is the lower-case part, AND THIS IS THE UPPER-CASE
  PART";
    cout << "first non-lower-case letter in str at: " << str.find_first_not_of
  (lower_case) << endl;

When run, find_first_not_of() finds the first upper-case letter in str at index 29 and displays this output:

    first non-lower-case letter in str at: 29

Related Topics: find, find_first_not_of, find_first_of, find_last_not_of, find_last_of, rfind