#include <iostream>
#include <regex>
#include <qregexp.h>
#include <QString>
using namespace std;
void regexStr();
int main(int argc, char *argv[])
{
// QCoreApplication a(argc, argv);
string a="AA55787z70955AA";
QStringList list;
regex w("\\d+|(([A-Z]|[a-z])+)");
smatch m;
while(regex_search(a,m,w))
{
std::string piece = m.str(); //qt string 转qstring
list.append(QString::fromStdString(piece));
a=m.suffix().str();
}
regexStr();
return 0;
// return a.exec();
}
void regexStr()
{
QString s="AA55787z70955AA";
QRegExp t("\\d+");
int pos=0;
while((pos = t.indexIn(s, pos)) != -1)
{
cout<<t.cap().toStdString()<<endl;
pos += t.matchedLength();
}
}
c++之正则表达式
最新推荐文章于 2022-11-16 14:47:07 发布