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. git 项目常用命令

    git remote -v 查看对应的远程仓库 git fetch origin master 将某个远程主机的更新,全部取回本地 git merge origin master 合并分支 git a ...

  2. bat mvn Maven中-DskipTests和-Dmaven.test.skip=true的区别 Maven 生命周期

    cd C:\Users\lt32806\git\tempest call mvn clean compile -Dmaven.test.skip=truepause Maven中-DskipTests ...

  3. Linux中断分层--工作队列

    1. 工作队列是一种将任务推后执行的方式,它把推后的任务交由一个内核线程去执行.这样中断的下半部会在进程上下文执行,他允许重新调度甚至睡眠.每个被推后的任务叫做“工作”,由这些工作组成的队列称为工作队 ...

  4. Js与标签属性

    关于在JS中设置标签属性 2017-10-09 23:04 by 清风221, 12790 阅读, 0 评论, 收藏, 编辑 Attribute 该属性主要是用来在标签行内样式,添加.删除.获取属性. ...

  5. 文献综述四:基于 UML 技术的客户关系管理系统实现

    一.基本信息 标题:基于 UML 技术的客户关系管理系统实现 时间:2015 出版源:电子设计工程 文件分类:uml技术的研究 二.研究背景 使用UML 建模技术和 B/S 架构访问模式,设计出可应用 ...

  6. maven+springboot+阿里大于

    问题:maven仓库无法找到taobao-sdk-java-auto-1.0.jar包 目的:将jar包添加到maven项目中 1.在官网下载jar包 2.将jar包放在d盘 3.mvn instal ...

  7. Oracle 客户端、服务器、数据库、数据库对象(表、视图等)的关系

    1.数据库服务器 所谓数据库服务器,只是在机器上安装了一个数据库管理软件,这个软件可以管理多个数据库.一般开发人员会针对每一个应用创建一个数据库 2.单实例数据库模式下的数据库服务器.数据库.数据库实 ...

  8. 解决 command not found: express

    需要先执行 sudo npm install -g express-generator 再安装 sudo npm install -g express 建立项目骨架 express -e   xxx

  9. 详解ASP.NET MVC Model验证

    ASP.NET mvc的最好的优点之一就是支持Model验证,这个特性很方便你可以选择在定义Model的时候在字段中采用特性进行注解约定,也可以在代码中自己进行手动验证.下面就来细说一下ASP.NET ...

  10. PAT 1040 Longest Symmetric String

    #include <cstdio> #include <cstdlib> using namespace std; ]; ]; int syslen(char str[], i ...