public member function
<string>

std::string::find_last_not_of

string (1)
size_t find_last_not_of (const string& str, size_t pos = npos) const;
c-string (2)
size_t find_last_not_of (const char* s, size_t pos = npos) const;
buffer (3)
size_t find_last_not_of (const char* s, size_t pos, size_t n) const;
character (4)
size_t find_last_not_of (char c, size_t pos = npos) const;
Find non-matching character in string from the end

Searches the string for the last character that does not match any of the characters specified in its arguments.

When pos is specified, the search only includes characters at or before position pos, ignoring any possible occurrences after pos.

Parameters

str
Another string with the set of characters to be used in the search.
pos
Position of the last character in the string to be considered in the search.
Any value greater than, or equal to, the string length (including string::npos) means that the entire string is searched.
Note: The first character is denoted by a value of 0 (not 1).
s
Pointer to an array of characters.
If argument n is specified (3), the first n characters in the array are used in the search.
Otherwise (2), a null-terminated sequence is expected: the length
of the sequence with the characters used in the search is determined by
the first occurrence of a null character.
n
Number of character values to search for.
c
Individual character to be searched for.

size_t is an unsigned integral type (the same as member typestring::size_type).

Return Value

The position of the first character that does not match.
If no such characters are found, the function returns string::npos.

size_t is an unsigned integral type (the same as member typestring::size_type).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// string::find_last_not_of
#include <iostream> // std::cout
#include <string> // std::string
#include <cstddef> // std::size_t int main ()
{
std::string str ("Please, erase trailing white-spaces \n");
std::string whitespaces (" \t\f\v\n\r"); std::size_t found = str.find_last_not_of(whitespaces);
if (found!=std::string::npos)
str.erase(found+1);
else
str.clear(); // str is all whitespace std::cout << '[' << str << "]\n"; return 0;
}
[Please, erase trailing white-spaces]

Complexity

Unspecified, but generally up to linear in the string length (or pos) times the number of characters to match (worst case).

Iterator validity

No changes.

Data races

The object is accessed.

Exception safety

If s does not point to an array long enough, it causes undefined behavior.
Otherwise, the function never throws exceptions (no-throw guarantee).

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 (public member function
)
string::replace
Replace portion of string (public member function
)
string::substr
Generate substring (public member function
)
http://www.cplusplus.com/reference/string/string/find_last_not_of/

std::string::find_last_not_of的更多相关文章

  1. c++ std::string 用法

    std::string用法总结 在平常工作中经常用到了string类,本人记忆了不好用到了的时候经常要去查询.在网上摘抄一下总结一下,为以后的查询方便: string类的构造函数: string(co ...

  2. std::string 用法总结

    标准C++中的string类的用法总结 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果离开了MFC框架,还有 ...

  3. std::string find 的返回值

    std::string  的方法 find,返回值类型是std::string::size_type, 对应的是查找对象在字符串中的位置(从0开始), 如果未查找到,该返回值是一个很大的数据(4294 ...

  4. std::string 用法

    string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化 string类的字符操作:const ...

  5. std::string类详解

    之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够.字符串长度等等,而且作为一个类出现,他集成的操作函数足以完成我们大多数情况下(甚至 ...

  6. QString 和std::string互转

    std::string cstr; QString qstring; //****从std::string 到QString qstring = QString(QString::fromLocal8 ...

  7. std::string的split函数

    刚刚要找个按空格分离std::string的函数, 结果发现了stackoverflow上的这个问题. 也没仔细看, 直接拿来一试, 靠, 不对啊, 怎么分离后多出个空字符串, 也就是 "a ...

  8. could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

    VS2008, 写一个简单的demo的时候出现了这个: 1>------ Build started: Project: GetExportTable, Configuration: Relea ...

  9. 源码阅读笔记 - 3 std::string 与 Short String Optimization

    众所周知,大部分情况下,操作一个自动(栈)变量的速度是比操作一个堆上的值的速度快的.然而,栈数组的大小是在编译时确定的(不要说 C99 的VLA,那货的 sizeof 是运行时计算的),但是堆数组的大 ...

随机推荐

  1. drf序列化器的实例

    应用目录结构: views.py from django.shortcuts import render # Create your views here. from django.views imp ...

  2. Maven-常规问题

    1.编译(compile)Maven项目时,报错: -Dmaven.multiModuleProjectDirectory system property is not set. 处理方案:Windo ...

  3. RMQ、POJ3264

    这里说几篇博客,建议从上到下看 https://blog.csdn.net/qq_31759205/article/details/75008659 https://blog.csdn.net/sgh ...

  4. esper(4-5)- Context 条件

    条件主要包含:Filter,Pattern,Crontab以及Time Period Filter主要就是对属性值的过滤,比如: create context NewUser partition by ...

  5. MVC Control 接收post请求的json数据

    [HttpPost] public string QueryInvoice() { string stream; using (var sr = new StreamReader(Request.In ...

  6. Angular4+NodeJs+MySQL 入门-05 接口调用

    接口调用 今天讲一下,如果在前端页面上通过调用后台接口,返回来的数据.把前面的几章结合起来. 这里所有用的代码在 https://github.com/xiaotuni/angular-map-htt ...

  7. 解决ios、微信移动端的position: fixed; 支持性不好的问题 && 禁用下拉暴露黑底的功能

    解决ios.微信移动端的position: fixed; 支持性不好的问题 在chrome中的多个部分使用了position: fixed之后,都可以正常的布局,但是放在微信上却出现了不能正常显示的问 ...

  8. 让C:\Users文件夹放在D盘

    新安装win7 在安装Win7的过程中,要求输入用户名及密码的时候,先不如输入任何信息,按“Shift+F10”呼出DOS窗口,输入以下命令: robocopy "C:\Users" ...

  9. innosetup的静默安装与卸载

    静默安装,就是减少程序与用户的交互,一站式的安装过程(一气呵成) 1. 静默安装参数 innosetup的静默安装是通过参数来控制的 1.1.  /silent                     ...

  10. RocketMQ3.2.6安装部署及调用

    RocketMQ3.2.6安装部署及调用 1.RocketMQ部署架构 所有IP都是127.0.0.1,其中NameServer一个,Broker一个,Producer一个,Consumer一个 2. ...