c++ - 删除特定字符后的所有内容

标签 c++ qt

我正在开发 Qt 应用程序。我有一些字符串,例如:

(@前的子字符串)

43243263@example.com

325754754@example.com

我要用

43243263

325754754

怎么做?

最佳答案

您可以使用QString::indexOfQString::mid 方法来提取所需的部分。

QString str = "43243263@example.com";
QString desired = str.mid(0, str.indexOf("@"));

关于c++ - 删除特定字符后的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35378612/

相关文章:

c++ - 为什么必须在何处以及为什么要放置"template"和"typename"关键字?

c++ - 如何在 eventFilter 中将 Left_Key 和 Right_Key 事件相互更改?

c++ - 如何在多行上编写 QString?

c++ - 在 Qt Quick 2 中嵌入 QWidget 对象

c++ - 使用 MinGW 的 g++ 在 Windows XP 中编译 Qt 程序

C++ While 循环在数组为零时停止

c++ - std::chrono::steady_clock::now 应该是 noexcept 吗?

c++ - QSet::find() 迭代器解引用出现 “cannot convert ‘this’ 指针”错误?

c# - GC.AddMemoryPressure() 不足以按时触发 Finalizer 队列执行

c++ - 删除与其他类共享的指针