当前位置:网站首页>Qt 字符串截取 查找字符串
Qt 字符串截取 查找字符串
2022-08-11 05:15:00 【双子座断点】
获取字符在字符串中的位置
QString str = "AT+LOC+LOCATION: 115.850441,33.004833";
QString s = "LOC";
str.indexOf(s); //3
str.indexOf(s, 6); //7
QString str = "AT+LOC+LOCATION";
QString s = "O";
str.lastIndexOf(s); //13
截取指定位置字符
QString str = "AT+LOC+LOCATION: 115.850441,33.004833";
QString s = str.mid(6); //"+LOCATION: 115.850441,33.004833"
QString s = str.mid(6, 9); //"+LOCATION"
分割字符串
QString str = "AT+LOC+LOCATION";
QStringList list = str.split("+");
for(int i = 0; i < list.count(); i++)
{
qDebug() << list.at(i);
}
//输出
"AT"
"LOC"
"LOCATION"
字符串以特定串开始
QString url = "https://www.baidu.com";
if(url.startsWith("https") && url.endsWith("com")) //true
//等价于
if(url.left(5) == "https" && url.right(3) == "com") //true
是否包含字符串
QString str = "AT+LOC+LOCATION: 115.850441,33.004833";
if(str.contains("LOC", Qt::CaseSensitive)) //true
边栏推荐
- 注解式编程小记
- Flask framework learning: template rendering and Get, Post requests
- Decryption of BitLocker
- Idea essential skills to improve work efficiency
- PCIe 接口 引脚定义 一览表
- pytorch安装笔记——Pytorch在conda+CUDA10.2环境安装task01
- task03 Pytorch模型定义
- (2) Docker installs Redis in practice (persistent AOF and RDB snapshots)
- task06 PyTorch生态
- Redis details
猜你喜欢
redis连接idea
(三)Redis 如何进行压测
vftpd本地可以连接,远程连接超时的解决
Blender 初教程
更新啦~人生重开模拟器自制
【win10+cuda7.5+cudnn6.0安装caffe⑥】报错及处理方式
Flask框架学习:模板渲染与Get,Post请求
(3) How Redis performs stress testing
(一)Docker安装Redis实战(一主二从三哨兵)
(3) Construction of a real-time performance monitoring platform (Grafana+Prometheus+Node_explorer+Jmeter)
随机推荐
(二)性能实时监控平台搭建(Grafana+Prometheus+Jmeter)
RK3399上的Tengine实践笔记
[Embedded open source library] The use of MultiButton, an easy-to-use event-driven button driver module
Flask框架学习:路由的尾部斜杠
IDEA模板总结
【翻译】博客游戏项目Q1K3 – 制作
基础数据之double和float区别
pytorch矩阵运算问题
【转载】CMake 语法 - 详解 CMakeLists.txt
(1) Construction of a real-time performance monitoring platform (Grafana+Influxdb+Jmeter)
Oracle常用语句归纳_持续更新
分库分表之sharding-proxy
Redis details
软件测试风险识别
BitLocker的解密
postman脚本的应用
基于 TF-IDF 文本匹配实战详细教程 数据+代码 可直接运行
并发编程之线程基础
redis连接idea
Map根据key值排序