When pos is specified the search only includes characters on or after position pos, ignoring any possible occurrences at previous character positions.
Notice that for a match to happen it is enough that one of the characters matches in the string (any of them). To search for an entire sequence of characters use find instead.
Parameters
- str
- string containing the characters to search for in the object. The first character in the string that compares equal to any of the characters in str is considered a match.
- s
- Array with a sequence of characters. The first character in the string that compares equal to any of the characters in this sequence is considered a match.
In the second member function version, the number of characters in the sequence of characters to search for is only determined by parameter n.
In the third version, a null-terminated sequence (c-string) is expected, and the amount of characters to search for is determined by its length, which is indicated by a null-character after the last character. - n
- Length of sequence of characters to search for.
- c
- Individual character to be searched for.
- pos
- Position of the first character in the string to be taken into consideration for possible matches. A value of 0 means that the entire string is considered.
Return Value
The position of the first occurrence in the string of any of the characters searched for.If the content is not found, the member value npos is returned.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
R*pl*c* th* v*w*ls *n th*s s*nt*nc* by *st*r*sks. |
Basic template member declarations
( basic_string<charT,traits,Allocator> )| 1 2 3 4 5 6 7 8 |
|
See also
| string::find | Find content in string (public member function) |
| string::find_last_of | Find character in string from the end (public member function) |
| string::find_first_not_of | Find absence of character in string |
| string::replace | Replace part of string (public member function) |
| string::substr | Generate substring (public member function) |
