正则表达式c++ Qt
Regular Expressions C++ Qt
QRegExp rx("\btest\b");
rx.indexIn("this is a test string");
QString captured = rx.cap(1);
std::string capturedstr = captured.toUtf8().constData();
std::cout << capturedstr;
我希望上面打印出test并匹配字符串中的单词test,但它似乎没有这样做。有人能解释一下吗?使用QT。
您的正则表达式中没有任何捕获父级,因此没有捕获组1。试试这个:
QRegExp rx("\b(test)\b");
将rx.cap(1)
替换为rx.cap(0)
相关文章:
- Qt VTK交互风格的信号到小部件
- QT在错误的班级中寻找空位
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 如何在Qt C++中更改光标
- 如何在MS Visual Studio 2019中运行QT UI
- QT通过C++添加映射QML项目
- libssh 的函数在构建 libssh 时无法在 Qt 和 cmake 错误中找到
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用Qt C++计算类似Git的SHA1哈希
- Qt focusObjectChanged example?
- 如何在cpp文件之间切换窗口?在Qt中
- Qt和C++:将QLineEdit添加到QTabWidget中
- 从数据库实时显示QT c++中的数据
- Qt Quick-如何仅从c++代码与qml属性交互
- 无法使用Qt Creator在Windows中构建yaml-cpp
- 如何在Qt中取消捕获字符串
- Qt SQLite没有查询或参数计数不匹配
- Qt SQlite无法创建表