本文整理汇总了C++中QRegularExpressionMatch类的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpressionMatch类的具体用法?C++ QRegularExpressionMatch怎么用?C++ QRegularExpressionMatch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QRegularExpressionMatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stop
void Player::play(QString stationId) {
stop();
if( !playList.contains(stationId))
{
return;
}
HSTREAM stream = BASS_StreamCreateURL(playList.value(stationId).toStdString().c_str(),0,BASS_STREAM_BLOCK|BASS_STREAM_STATUS|BASS_STREAM_AUTOFREE,MyDownload,0);
BASS_Start();
if( stream)
{
bool buffering = true;
while(buffering)
{
QWORD progress = BASS_StreamGetFilePosition(stream,BASS_FILEPOS_BUFFER)*100/BASS_StreamGetFilePosition(stream,BASS_FILEPOS_END);
webView()->page()->mainFrame()->evaluateJavaScript(QString("PlayerHud.updateBufforStatus("+ QString::number(progress) +")"));
if( progress>=100)
{
buffering = false;
webView()->page()->mainFrame()->evaluateJavaScript("PlayerHud.clearBufforStatus()");
}
}
const char *meta=BASS_ChannelGetTags(stream,BASS_TAG_META);
if( !meta)
{
meta = BASS_ChannelGetTags(stream,BASS_TAG_OGG);
}
if( meta)
{
qDebug() << meta;
QRegularExpression rx("StreamTitle='(.+)';StreamUrl");
QRegularExpressionMatch match = rx.match(QString(meta));
if (match.hasMatch()) {
qDebug() << match.captured(1);
webView()->page()->mainFrame()->evaluateJavaScript("setRadiostationTag('"+ match.captured(1) +"')");
}
}
BASS_ChannelPlay(stream,FALSE);
playStatus = true;
}
else
{
qDebug() << BASS_ErrorGetCode();
return;
}
return;
}
示例2: QRegularExpression
void Template::translate(ITemplateTranslationProvider &provider)
{
//This regex captures expressions of the form
//<?= tr("This is a test") ?> and <?= tr("optional %1 parameters %2","bla","blu") ?>
//The first capture group is the key (untranslated string), the second the optional list of parameters
const QRegularExpression regexp = QRegularExpression("<\\?=\\s*tr\\(\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"((?:,\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")*)\\s*\\)\\?>");
//This one is used to extract the parameters using global matching
const QRegularExpression paramExp = QRegularExpression(",\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"");
int offset = 0;
QRegularExpressionMatch match;
do
{
match = regexp.match(*this,offset);
if(match.hasMatch())
{
int start = match.capturedStart(0);
int len = match.capturedLength(0);
QString key = match.captured(1);
//replace escaped double and single quotes
key.replace("\\\"","\"");
key.replace("\\'", "'");
QString translation = provider.getTranslation(key);
//find out if we have optional parameters
if(match.capturedLength(2)>0)
{
QString params = match.captured(2);
//extract each optional parameter
QRegularExpressionMatchIterator it = paramExp.globalMatch(params);
while(it.hasNext())
{
QRegularExpressionMatch paramMatch = it.next();
QString param = paramMatch.captured(1);
//replace escaped quotes
param.replace("\\\"","\"");
param.replace("\\'", "'");
//apply the param
translation = translation.arg(param);
}
}
this->replace(start,len,translation);
offset = start+translation.length();
}
}while(match.hasMatch());
}
示例3: QProcess
void AccountsWorker::refreshADDomain()
{
QProcess *process = new QProcess(this);
process->start("/opt/pbis/bin/enum-users");
connect(process, &QProcess::readyReadStandardOutput, this, [=] {
QRegularExpression re("Name:\\s+(\\w+)");
QRegularExpressionMatch match = re.match(process->readAll());
m_userModel->setIsJoinADDomain(match.hasMatch());
});
connect(process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), process, &QProcess::deleteLater);
}
示例4: it
Provider *Provider::createForUrl(const QUrl &url, QObject *parent)
{
QMapIterator<QString, QRegularExpression> it(endpointToUrlSchemes);
while (it.hasNext()) {
it.next();
QRegularExpressionMatch match = it.value().match(url.toString());
if (match.hasMatch()) {
return new Provider(it.key(), parent);
}
}
return 0;
}
示例5: parseVersion
static bool parseVersion(const QString &text, int &version)
{
// The version in Uncrustify is printed like "uncrustify 0.62"
const QRegularExpression rx(QLatin1String("([0-9]{1})\\.([0-9]{2})"));
const QRegularExpressionMatch match = rx.match(text);
if (!match.hasMatch())
return false;
const int major = match.captured(1).toInt() * 100;
const int minor = match.captured(2).toInt();
version = major + minor;
return true;
}
示例6: re
void CellReference::init(const QString &cell_str)
{
// Try this "^'?([A-Za-z0-9._ ]*)'?:?\\$?([A-Z]{1,3})\\$?(\\d+)$"
static QRegularExpression re(QStringLiteral("^\\$?([A-Z]{1,3})\\$?(\\d+)$"));
QRegularExpressionMatch match = re.match(cell_str);
if (match.hasMatch()) {
const QString col_str = match.captured(1);
const QString row_str = match.captured(2);
_row = row_str.toInt();
_column = col_from_name(col_str);
// TODO _sheet
}
}
示例7: re
bool QGCAudioWorker::_getMillisecondString(const QString& string, QString& match, int& number) {
static QRegularExpression re("([0-9]+ms)");
QRegularExpressionMatchIterator i = re.globalMatch(string);
while (i.hasNext()) {
QRegularExpressionMatch qmatch = i.next();
if (qmatch.hasMatch()) {
match = qmatch.captured(0);
number = qmatch.captured(0).replace("ms", "").toInt();
return true;
}
}
return false;
}
示例8: sFormatPrefix
QStringList CaViewerScanner::getImageSeries(QString sPath, QString sFileName, QString &sRetBaseName)
{
// creates list components based on sFilename (eg. .../foo_t0001.tif)
QStringList slImageSeries;
// checks whether the filename matches the format or not
const QString sFormatPrefix("^(?<name>.+)");
const QString sFormatNumber("_t(?<num>\\d{4})");
const QString sFormatSuffix("(?<dotext>\\..{1,3})$");
const QRegularExpression regexpSeries(sFormatPrefix + sFormatNumber + sFormatSuffix);
const QRegularExpressionMatch matchSeries = regexpSeries.match(sFileName);
if(matchSeries.hasMatch())
{ // match found (i.e. there are related files in the same folder)
sRetBaseName = matchSeries.captured("name");
const QString sExtension = matchSeries.captured("dotext");
const QDir dir(sPath);
const QStringList slAllFiles = dir.entryList(QDir::Files, QDir::Name);
QRegularExpression regexpFileName(QRegularExpression::escape(sRetBaseName) + sFormatNumber
+ QRegularExpression::escape(sExtension));
int nSequence = 0;
for(int count = 0; count < slAllFiles.size(); ++count)
{
QRegularExpressionMatch match = regexpFileName.match(slAllFiles.at(count));
if(match.hasMatch())
{
int fileNum = match.captured("num").toInt();
if(fileNum != nSequence)
return slImageSeries;
else
{
slImageSeries << slAllFiles.at(count);
++nSequence;
}
}
}
}
else
{ // no match found
const QRegularExpression regexpSingle(sFormatPrefix + sFormatSuffix);
const QRegularExpressionMatch matchSingle = regexpSingle.match(sFileName);
if(matchSingle.hasMatch())
{
sRetBaseName = matchSingle.captured("name");
slImageSeries << sFileName;
}
}
return slImageSeries;
}
示例9: while
QString StringUtils::htmlEncode(
QString text, bool urlAsLinks, bool newlineAsBr) {
QString s;
QHash<int,int> linksIndexes; // start of link index -> length of link
if (urlAsLinks) {
QRegularExpressionMatchIterator it = linkRe.globalMatch(text);
while (it.hasNext()) {
QRegularExpressionMatch match = it.next();
linksIndexes.insert(match.capturedStart(0), match.capturedLength(0));
}
}
for (int i = 0; i < text.length(); ) {
if (urlAsLinks && linksIndexes.contains(i)) {
int l = linksIndexes.value(i);
QString html = htmlEncode(text.mid(i, l), false), href = html;
href.replace("\"", "%22");
s.append("<a href=\"").append(href).append("\">").append(html)
.append("</a>");
i += l;
} else {
const QChar c = text.at(i);
switch(c.toLatin1()) {
case '<':
s.append("<");
break;
case '>':
s.append(">");
break;
case '&':
s.append("&");
break;
case '"':
s.append(""");
break;
case '\'':
s.append("'");
break;
case '\n':
if (newlineAsBr)
s.append("<br/>\n");
else
s.append(c);
break;
default:
s.append(c);
}
++i;
}
}
return s;
}
示例10: html
QUrl TheHatAndFat::extractStripImageUrl(QByteArray data)
{
QString html(data);
QRegularExpression reg("<img[^>]*src=\"(https://thehatandfat.files.wordpress.com/[^\"]*)\"");
QRegularExpressionMatch match = reg.match(html);
if (!match.hasMatch()) {
return QUrl();
}
QString src = match.captured(1);
return QUrl(src);
}
示例11: html
QUrl FoxTrot::extractStripImageUrl(QByteArray data)
{
QString html(data);
QRegularExpression reg("<img[^>]*class=\"strip\".*src=\"([^\"]*)\"");
QRegularExpressionMatch match = reg.match(html);
if (!match.hasMatch()) {
return QUrl();
}
QString src = match.captured(1);
return QUrl(src);
}
示例12: html
QUrl Sigmund::extractStripImageUrl(QByteArray data)
{
QString html(data);
QRegularExpression reg("<img[^>]*src=(strips/[^ ]*) ");
QRegularExpressionMatch match = reg.match(html);
if (!match.hasMatch()) {
return QUrl();
}
QString src = match.captured(1);
return QUrl("http://www.sigmund.nl/" + src);
}
示例13: QRegularExpression
bool RawHtmlPostprocessor::isblocklevel(const QString &html)
{
QRegularExpressionMatch m = QRegularExpression("^\\<\\/?([^ >]+)").match(html);
if ( m.hasMatch() ) {
QChar ch = m.captured(1).at(0);
// SPECIAL_CHARS: !, ?, @, %
if ( SPECIAL_CHARS.contains(ch) ) {
//! Comment, php etc...
return true;
}
return util::isBlockLevel(m.captured(1));
}
return false;
}
示例14: foreach
foreach (OnePartRule rule, onepartrules)
{
QRegularExpressionMatchIterator i = rule.pattern.globalMatch(text);
while (i.hasNext())
{
QRegularExpressionMatch match = i.next();
int length = match.capturedLength();
if (length == 0)
continue;
int start = match.capturedStart();
setFormat(start, length, rule.format);
}
}
示例15: html
QUrl ViiviJaWagner::extractStripImageUrl(QByteArray data)
{
QString html(data);
QRegularExpression reg("<img[^>]*src=\"(.*/webkuva/[^\"]*)\"");
QRegularExpressionMatch match = reg.match(html);
if (!match.hasMatch()) {
return QUrl();
}
QString src = match.captured(1);
return QUrl(src);
}