section字符串分割
来源:互联网 发布:手机淘宝怎么定时上架 编辑:程序博客网 时间:2024/05/17 08:41
QString QString::section(QChar sep, int start, int end = -1, SectionFlags flags = SectionDefault) const
This function returns a section of the string.
This string is treated as a sequence of fields separated by the character, sep. The returned string consists of the fields from position start to position end inclusive. If end is not specified, all fields from position start to the end of the string are included. Fields are numbered 0, 1, 2, etc., counting from the left, and -1, -2, etc., counting from right to left.
The flags argument can be used to affect some aspects of the function's behavior, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see SectionFlags.
QString str;
QString csv = "forename,middlename,surname,phone";
QString path = "/usr/local/bin/myapp"; // First field is empty
QString::SectionFlag flag = QString::SectionSkipEmpty;
str = csv.section(',', 2, 2); // str == "surname" 从左到右是分成 0,1,2 个块 从右到左是分成 -1 -2 -3 个块序号
str = path.section('/', 3, 4); // str == "bin/myapp" 这个第一个块是空白,第三块是bin,第四块是myapp
This function returns a section of the string.
This string is treated as a sequence of fields separated by the character, sep. The returned string consists of the fields from position start to position end inclusive. If end is not specified, all fields from position start to the end of the string are included. Fields are numbered 0, 1, 2, etc., counting from the left, and -1, -2, etc., counting from right to left.
The flags argument can be used to affect some aspects of the function's behavior, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see SectionFlags.
QString str;
QString csv = "forename,middlename,surname,phone";
QString path = "/usr/local/bin/myapp"; // First field is empty
QString::SectionFlag flag = QString::SectionSkipEmpty;
str = csv.section(',', 2, 2); // str == "surname" 从左到右是分成 0,1,2 个块 从右到左是分成 -1 -2 -3 个块序号
str = path.section('/', 3, 4); // str == "bin/myapp" 这个第一个块是空白,第三块是bin,第四块是myapp
str = path.section('/', 3, 3, flag); // str == "myapp"
0 0
- section字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 【原创】有想打开却打不开的网页吗…
- PHPExcel 多工作表 导入
- 【转载】这种教育孩子的方式太绝了…
- 【转载】Sublime Text 2…
- 【原创】mysql 触发器trigger…
- section字符串分割
- 【转载】ubuntu12.04 安装lin…
- 【原创】linux ubuntu12.04&n…
- MySQL使用Batch批量处理
- 国省州市县四级关联表
- 【原创】linux目录突然消失的解决…
- 【原创】Linux ftp lftp
- ubuntu 安装python2.7
- 【原创】 linux Screen 使用