- {
- /**
- * \s 表示一个\t、一个\n等
- * \s Matches a whitespace character (QChar::isSpace()).
- * \s* 多个
- * \s+ 至少一个
- * \s{2} 两个
- * \s{1,2} 一个到两个
- * \w 表示一个字母、一个数字、一个汉字等
- * \w Matches a word character (QChar::isLetterOrNumber(), QChar::isMark(), or '_').
- * \w* 多个
- * \w+ 至少一个
- * \w{2} 两个
- * \w{1,2} 一个到两个
- * () 表示提取的位置
- */
- QString Output = "select obid from cey_bt_table where ch_billno = 'Q001' ";
- QRegExp rx(R"(select\s*(\w*)\s*from\s*(\w*)\s*where\s*(\w*)\s*=\s*'(\w*)'\s*)");
- rx.indexIn(Output);
- QStringList qsl = rx.capturedTexts();
-
- for(int i=0; i
- {
- qDebug()<<"Da Data Thing: "<< i << " Da Value Thing: " << qsl.at(i);
- }
- return 1;
- }
运行结果:
Da Data Thing: 0 Da Value Thing: "select obid from cey_bt_table where ch_billno = 'Q001' "
Da Data Thing: 1 Da Value Thing: "obid"
Da Data Thing: 2 Da Value Thing: "cey_bt_table"
Da Data Thing: 3 Da Value Thing: "ch_billno"
Da Data Thing: 4 Da Value Thing: "Q001"
实例2 mac地址相关
- {
- /**
- * \d 表示一个数字
- * \d Matches a digit (QChar::isDigit()).
- * \d+ 表示重复一次或者多次 1、12、23
- * \d* 表示重复零次或者多次 _、12、11
- * \d{2} 表示只能匹配两个字符
- */
- QString Output;
- Output="Duration: 00:01:25.65, start: 0.050000, bitrate: 5200 kb/s";
- QRegExp rx = QRegExp(R"(Duration:\s*(\d{2}:\d{2}:\d{2}.\d{2}),\s*start:\s*(\d+\.\d+),\s*bitrate:\s*(\d*)\s*kb/s)");
-
- rx.indexIn(Output);
- QStringList qsl = rx.capturedTexts();
-
- for(int i=0; i
- {
- qDebug()<<"Da Data Thing: "<< i << " Da Value Thing: " << qsl.at(i);
- }
- }
运行结果:
Da Data Thing: 0 Da Value Thing: "Duration: 00:01:25.65, start: 0.050000, bitrate: 5200 kb/s"
Da Data Thing: 1 Da Value Thing: "00:01:25.65"
Da Data Thing: 2 Da Value Thing: "0.050000"
Da Data Thing: 3 Da Value Thing: "5200"
-
相关阅读:
MySQL问题:2002 - Can‘t connect to server on ‘localhost‘(10061)【已解决】
【人工智能,机器学习,统计学习,科学表征】开源商用与研发合作
FastDFS 存储原理
Git 恢复已删除的branch
【C++】匿名对象 ② ( 将 “ 匿名对象 “ 初始化给变量 | 将 “ 匿名对象 “ 赋值给变量 )
说透缓存一致性与内存屏障
异常检测:探索数据深层次背后的奥秘《中篇》
Python自动控制(三)
angular2网页前端执行流程
实现自定义Spring Boot Starter
-
原文地址:https://blog.csdn.net/ch593030323/article/details/128133499