• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QRegularExpression函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QRegularExpression函数的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpression函数的具体用法?C++ QRegularExpression怎么用?C++ QRegularExpression使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了QRegularExpression函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: QObject

KNMusicLrcParser::KNMusicLrcParser(QObject *parent) :
    QObject(parent),
    m_frameCatchRegExp(QRegularExpression("\\[[^\\]]*\\]")),
    m_noneNumberRegExp(QRegularExpression("[^0-9]")),
    m_utf8Codec(QTextCodec::codecForName("UTF-8")),
    m_localeCodec(knI18n->localeCodec())
{
}
开发者ID:Kreogist,项目名称:Mu,代码行数:8,代码来源:knmusiclrcparser.cpp


示例2: cleanupFileName

/**
 * Does a file name cleanup
 */
QString Note::cleanupFileName(QString name) {
    // remove characters from the name that are problematic
    name.remove(QRegularExpression("[\\/\\\\:]"));

    // remove multiple whitespaces from the name
    name.replace(QRegularExpression("\\s+"), " ");

    return name;
}
开发者ID:guija,项目名称:QOwnNotes,代码行数:12,代码来源:note.cpp


示例3: addAvion

void AvionShow::addAvion()
{
    Direction * dir=dynamic_cast<Direction *>(g());
    QString idc,idm;
    idc=_idc->model()->index(0,0).data().toString().split(QRegularExpression("\\s+"))[0];
    idm=_idm->model()->index(0,0).data().toString().split(QRegularExpression("\\s+"))[0];
    dir->setIAvion();
    connect(dir,SIGNAL(doneAddingAvion()),this,SLOT(maktir3ambetfidbascava()));
    dir->addAvion(idm,idc,ui->IdAvC->text(),"0");
}
开发者ID:NZBinome,项目名称:Genie-Logicel,代码行数:10,代码来源:avionshow.cpp


示例4: defined

QRegularExpression SystemFactory::supportedUpdateFiles() {
#if defined(Q_OS_WIN)
  return QRegularExpression(QSL(".+win.+\\.(exe|7z)"));
#elif defined(Q_OS_MAC)
  return QRegularExpression(QSL(".dmg"));
#elif defined(Q_OS_LINUX)
  return QRegularExpression(QSL(".AppImage"));
#else
  return QRegularExpression(QSL(".*"));
#endif
}
开发者ID:martinrotter,项目名称:rssguard,代码行数:11,代码来源:systemfactory.cpp


示例5: QRegularExpression

void PsUpdateDownloader::initOutput() {
	QString fileName;
	QRegularExpressionMatch m = QRegularExpression(qsl("/([^/\\?]+)(\\?|$)")).match(updateUrl);
	if (m.hasMatch()) {
		fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
	}
	if (fileName.isEmpty()) {
		fileName = qsl("tupdate-%1").arg(rand());
	}
	QString dirStr = cWorkingDir() + qsl("tupdates/");
	fileName = dirStr + fileName;
	QFileInfo file(fileName);

	QDir dir(dirStr);
	if (dir.exists()) {
		QFileInfoList all = dir.entryInfoList(QDir::Files);
		for (QFileInfoList::iterator i = all.begin(), e = all.end(); i != e; ++i) {
			if (i->absoluteFilePath() != file.absoluteFilePath()) {
				QFile::remove(i->absoluteFilePath());
			}
		}
	} else {
		dir.mkdir(dir.absolutePath());
	}
	outputFile.setFileName(fileName);
	if (file.exists()) {
		uint64 fullSize = file.size();
		if (fullSize < INT_MAX) {
			int32 goodSize = (int32)fullSize;
			if (goodSize % UpdateChunk) {
				goodSize = goodSize - (goodSize % UpdateChunk);
				if (goodSize) {
					if (outputFile.open(QIODevice::ReadOnly)) {
						QByteArray goodData = outputFile.readAll().mid(0, goodSize);
						outputFile.close();
						if (outputFile.open(QIODevice::WriteOnly)) {
							outputFile.write(goodData);
							outputFile.close();

							QMutexLocker lock(&mutex);
							already = goodSize;
						}
					}
				}
			} else {
				QMutexLocker lock(&mutex);
				already = goodSize;
			}
		}
		if (!already) {
			QFile::remove(fileName);
		}
	}
}
开发者ID:jubalh,项目名称:tdesktop,代码行数:54,代码来源:pspecific_mac.cpp


示例6: blocker

/**
 * Parses a text document and builds the navigation tree for it
 */
void NavigationWidget::parse(QTextDocument *document) {
    const QSignalBlocker blocker(this);
    Q_UNUSED(blocker);

    setDocument(document);
    clear();
    _lastHeadingItemList.clear();

    for (int i = 0; i < document->blockCount(); i++) {
        QTextBlock block = document->findBlockByNumber(i);
        int elementType = block.userState();

        // ignore all non headline types
        if ((elementType < pmh_H1) || (elementType > pmh_H6)) {
            continue;
        }

        QString text = block.text();

        text.remove(QRegularExpression("^#+"))
                .remove(QRegularExpression("#+$"))
                .remove(QRegularExpression("^\\s+"))
                .remove(QRegularExpression("^=+$"))
                .remove(QRegularExpression("^-+$"));

        if (text.isEmpty()) {
            continue;
        }

        QTreeWidgetItem *item = new QTreeWidgetItem();
        item->setText(0, text);
        item->setData(0, Qt::UserRole, block.position());
        item->setToolTip(0, tr("headline %1").arg(elementType - pmh_H1 + 1));

        // attempt to find a suitable parent item for the element type
        QTreeWidgetItem *lastHigherItem = findSuitableParentItem(elementType);

        if (lastHigherItem == NULL) {
            // if there wasn't a last higher level item then add the current
            // item to the top level
            addTopLevelItem(item);
        } else {
            // if there was a last higher level item then add the current
            // item as child of that item
            lastHigherItem->addChild(item);
        }

        _lastHeadingItemList[elementType] = item;
    }

    expandAll();
}
开发者ID:XavierCLL,项目名称:QOwnNotes,代码行数:55,代码来源:navigationwidget.cpp


示例7: 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());
}
开发者ID:PhiTheta,项目名称:stellarium,代码行数:52,代码来源:template.cpp


示例8: text

void ScintillaEditor::changeSpacesToTabs() {
/*  -changes spaces into tabs */
    //go through the text line by line and replace spaces with tabs
    QStringList editorTextLines = text().split( QRegularExpression("\n") );

    QString textExpression = tr("\\s{2,%1}").arg( tabWidth() );

    for (int i = 0, l = editorTextLines.length(); i < l; i++) {
        editorTextLines[i].replace( QRegularExpression(textExpression), "\t");
    }

    setText( editorTextLines.join("\n") );
}
开发者ID:Leonardo2718,项目名称:Lepton_Editor,代码行数:13,代码来源:scintillaeditor.cpp


示例9: Q_D

void FloorCapVector::UnpackVector()
{
    Q_D(FloorCapVector);
    d->m_FloorVal.clear();
    d->m_CapVal.clear();
    if (d->m_Vector.isEmpty()) return;
    ExtractAnchorDate();
    QString TempVec(d->m_Vector.trimmed().toUpper());
    QStringList StringParts = TempVec.trimmed().toUpper().split(QRegularExpression("\\s"), QString::SkipEmptyParts);
    int StepLen;
    QString TempStr;
    for (int i = 1; i < StringParts.size(); i += 2) {
        TempStr = StringParts.at(i);
        TempStr.replace(QRegularExpression("\\D"), "");
        StepLen = TempStr.toInt();
        TempStr = StringParts.at(i);
        TempStr.replace(QRegularExpression("\\d"), "");
        for (int j = 0; j < StepLen; j++) {
            QString RawVal = StringParts.at(i - 1);
            RawVal.replace("[", "");
            RawVal.replace("]", "");
            auto CapFloor = RawVal.split(',', QString::KeepEmptyParts);
            if (CapFloor.size() > 0) {
                if (CapFloor.at(0).isEmpty()) d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
                else d->m_FloorVal.append(std::make_shared<double>(CapFloor.at(0).toDouble()));
            }
            else d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
            if (CapFloor.size() > 1) {
                if (CapFloor.at(1).isEmpty()) d->m_CapVal.append(std::shared_ptr<double>(nullptr));
                else d->m_CapVal.append(std::make_shared<double>(CapFloor.at(1).toDouble()));
            }
            else d->m_CapVal.append(std::shared_ptr<double>(nullptr));
        }
    }
    {
        QString RawVal = StringParts.last();
        RawVal.replace("[", "");
        RawVal.replace("]", "");
        auto CapFloor = RawVal.split(',', QString::KeepEmptyParts);
        if (CapFloor.size() > 0) {
            if (CapFloor.at(0).isEmpty()) d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
            else d->m_FloorVal.append(std::make_shared<double>(CapFloor.at(0).toDouble()));
        }
        else d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
        if (CapFloor.size() > 1) {
            if (CapFloor.at(1).isEmpty()) d->m_CapVal.append(std::shared_ptr<double>(nullptr));
            else d->m_CapVal.append(std::make_shared<double>(CapFloor.at(1).toDouble()));
        }
        else d->m_CapVal.append(std::shared_ptr<double>(nullptr));
    }
}
开发者ID:VSRonin,项目名称:CLOModel,代码行数:51,代码来源:FloorCapVector.cpp


示例10: QRegularExpression

QPointF SymbolDataEditor::getMovePoint(const QString &path)
{
    QString move = QRegularExpression("^[mM] *-?\\d+\\.?\\d*,? ?-?\\d+\\.?\\d*").match(path).captured();
    move.remove(QRegularExpression("^[mM] *"));
    int indexOfSeparator = move.indexOf(QRegularExpression("[ ,]"));

    if (indexOfSeparator >= 0 && indexOfSeparator + 1 < move.size())
    {
        QString x = move.left(indexOfSeparator);
        QString y = move.mid(indexOfSeparator + 1);
        return QPointF(x.toDouble(), y.toDouble());
    }

    return QPointF(0.0, 0.0);
}
开发者ID:aizenbit,项目名称:Scribbler,代码行数:15,代码来源:symboldataeditor.cpp


示例11: createSafeSheetName

/*
  Creates a valid sheet name
    minimum length is 1
    maximum length is 31
    doesn't contain special chars: / \ ? * ] [ :
    Sheet names must not begin or end with ' (apostrophe)

  Invalid characters are replaced by one space character ' '.
 */
QString createSafeSheetName(const QString &nameProposal)
{
    if (nameProposal.isEmpty())
        return QString();

    QString ret = nameProposal;
    if (nameProposal.contains(QRegularExpression(QStringLiteral("[/\\\\?*\\][:]+"))))
        ret.replace(QRegularExpression(QStringLiteral("[/\\\\?*\\][:]+")), QStringLiteral(" "));
    while(ret.contains(QRegularExpression(QStringLiteral("^\\s*'\\s*|\\s*'\\s*$"))))
        ret.remove(QRegularExpression(QStringLiteral("^\\s*'\\s*|\\s*'\\s*$")));
    ret = ret.trimmed();
    if (ret.size() > 31)
        ret = ret.left(31);
    return ret;
}
开发者ID:BlackNib,项目名称:QtXlsxWriter,代码行数:24,代码来源:xlsxutility.cpp


示例12: QString

void LoadJob::onNewEntry(const Archive::Entry *entry)
{
    m_extractedFilesSize += entry->property("size").toLongLong();
    m_isPasswordProtected |= entry->property("isPasswordProtected").toBool();

    if (entry->isDir()) {
        m_dirCount++;
    } else {
        m_filesCount++;
    }

    if (m_isSingleFolderArchive) {
        // RPM filenames have the ./ prefix, and "." would be detected as the subfolder name, so we remove it.
        const QString fullPath = entry->fullPath().replace(QRegularExpression(QStringLiteral("^\\./")), QString());
        const QString basePath = fullPath.split(QLatin1Char('/')).at(0);

        if (m_basePath.isEmpty()) {
            m_basePath = basePath;
            m_subfolderName = basePath;
        } else {
            if (m_basePath != basePath) {
                m_isSingleFolderArchive = false;
                m_subfolderName.clear();
            }
        }
    }
}
开发者ID:aelog,项目名称:ark,代码行数:27,代码来源:jobs.cpp


示例13: saveAllSheetsToImages

void MainWindow::saveAllSheetsToImages(const QString &fileName)
{
    int indexOfExtension = fileName.indexOf(QRegularExpression("\\.\\w+$"), 0);
    QString currentFileName;
    currentSheetNumber = -1;
    ui->toolBar->actions()[ToolButton::Next]->setEnabled(true);
    ui->svgView->hideBorders(true);

    while (ui->toolBar->actions()[ToolButton::Next]->isEnabled()) //while "Next Sheet" tool button is enabled,
    {                                                             //i.e. while rendering all sheets
        renderNextSheet();
        currentFileName = fileName;

        if (currentSheetNumber > 0 || ui->toolBar->actions()[ToolButton::Next]->isEnabled())
            //i.e. there is more than one sheet
            currentFileName.insert(indexOfExtension, QString("_%1").arg(currentSheetNumber));

        saveSheet(currentFileName);
    }

    ui->svgView->hideBorders(false);

    //we used renderNextSheet() for the first sheet instead of renderFirstSheet()
    //so we need to check the number of sheet and disable previous toolbutton if needed
    if (currentSheetNumber == 0)
        ui->toolBar->actions()[ToolButton::Previous]->setDisabled(true);
}
开发者ID:aizenbit,项目名称:Scribbler,代码行数:27,代码来源:mainwindow.cpp


示例14: QRegularExpression

void WebLoadManager::onMeta() {
	QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
	if (!reply) return;

	Replies::iterator j = _replies.find(reply);
	if (j == _replies.cend()) { // handled already
		return;
	}
	webFileLoaderPrivate *loader = j.value();

	typedef QList<QNetworkReply::RawHeaderPair> Pairs;
	Pairs pairs = reply->rawHeaderPairs();
	for (Pairs::iterator i = pairs.begin(), e = pairs.end(); i != e; ++i) {
		if (QString::fromUtf8(i->first).toLower() == "content-range") {
			QRegularExpressionMatch m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(i->second));
			if (m.hasMatch()) {
				loader->setProgress(qMax(qint64(loader->data().size()), loader->already()), m.captured(1).toLongLong());
				if (!handleReplyResult(loader, WebReplyProcessProgress)) {
					_replies.erase(j);
					_loaders.remove(loader);
					delete loader;

					reply->abort();
					reply->deleteLater();
				}
			}
		}
	}
}
开发者ID:2asoft,项目名称:tdesktop,代码行数:29,代码来源:file_download.cpp


示例15: set

void MCGUILayoutAxis::set(const QString &str) {
    QString s = str;
    if (s.size() <= 0)
        return;
    s.replace(" ", "");
    QStringList a = s.split(QRegularExpression("(?=\\-|\\+)"));
    components.clear();
    for (QString p : a) {
        if (p.length() <= 0)
            continue;
        int i = p.indexOf("%");
        Component c;
        if (i >= 0) {
            c.value = p.midRef(0, i).toFloat() / 100.f;
            if (p.endsWith("x"))
                c.unit = Component::Unit::PERCENT_X;
            else if (p.endsWith("y"))
                c.unit = Component::Unit::PERCENT_Y;
            else
                c.unit = (axis == Axis::X ? Component::Unit::PERCENT_X : Component::Unit::PERCENT_Y);
        } else {
            if (p.endsWith("px"))
                c.value = p.midRef(0, p.length() - 2).toFloat();
            else
                c.value = p.toFloat();

            c.unit = Component::Unit::PIXELS;
        }
        components.push_back(c);
    }
}
开发者ID:MCMrARM,项目名称:mcpe-json-editor,代码行数:31,代码来源:MinecraftGUIComponent.cpp


示例16: parseImageFormat

  ImageOutputFormat parseImageFormat( const QString &format )
  {
    if ( format.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 ||
         format.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 )
    {
      return PNG;
    }
    else if ( format.compare( QLatin1String( "jpg " ), Qt::CaseInsensitive ) == 0  ||
              format.compare( QLatin1String( "image/jpeg" ), Qt::CaseInsensitive ) == 0 )
    {
      return JPEG;
    }
    else
    {
      // lookup for png with mode
      QRegularExpression modeExpr = QRegularExpression( QStringLiteral( "image/png\\s*;\\s*mode=([^;]+)" ),
                                    QRegularExpression::CaseInsensitiveOption );

      QRegularExpressionMatch match = modeExpr.match( format );
      QString mode = match.captured();
      if ( mode.compare( QLatin1String( "16bit" ), Qt::CaseInsensitive ) == 0 )
        return PNG16;
      if ( mode.compare( QLatin1String( "8bit" ), Qt::CaseInsensitive ) == 0 )
        return PNG8;
      if ( mode.compare( QLatin1String( "1bit" ), Qt::CaseInsensitive ) == 0 )
        return PNG1;
    }

    return UNKN;
  }
开发者ID:exlimit,项目名称:QGIS,代码行数:30,代码来源:qgswmsutils.cpp


示例17: QRegularExpression

void Highlighter::addRule(const QString &pattern, const QBrush &brush)
{
	HighlightingRule rule;
	rule.pattern = QRegularExpression(pattern);
	rule.format.setForeground(brush);
	highlightingRules.append(rule);
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:7,代码来源:syntax_highlighter.cpp


示例18: file

void ExperimentConditionsDialog::read_energies_from_file(QString filename) {
    energies.clear();
    QFile file(filename);
    if(file.open(QFile::ReadOnly)) {
        QTextStream in(&file);
        auto line = in.readLine();
        while(!line.isNull()) {
            double energy = line.section(QRegularExpression("\\s+"), 0, 0).toDouble();
            double intensity = line.section(QRegularExpression("\\s+"), 1, 1).toDouble();
            energies[energy] += intensity;
            line = in.readLine();
        }
    } else {
        QMessageBox::critical(this, "File access error", "Could not open file " + ui->projectile_energy_file_name->text());
    }
}
开发者ID:semkiv,项目名称:SimulApp,代码行数:16,代码来源:experimentconditionsdialog.cpp


示例19: QObject

Shield::Shield(QObject *parent) :
QObject(parent), d_ptr(new ShieldPrivate)
{
	Q_D(Shield);
	ins = this;
	QJsonArray s = Config::getValue<QJsonArray>("/Shield/Sender");
	QJsonArray r = Config::getValue<QJsonArray>("/Shield/Regexp");
	for (const QJsonValue &item : s){
		d->shieldS.insert(item.toString());
	}
	for (const QJsonValue &item : r){
		d->shieldR.append(QRegularExpression(item.toString()));
	}
	int group = Config::getValue("/Shield/Group", 0);
	for (int i = 7; i >= 0; --i){
		d->shieldG[i] = group & 1;
		group = group >> 1;
	}
	connect(Config::instance(), &Config::aboutToSave, [d]{
		QJsonArray s, r;
		for (auto &item : d->shieldS){
			s.append(item);
		}
		Config::setValue("/Shield/Sender", s);
		for (auto &item : d->shieldR){
			r.append(item.pattern());
		}
		Config::setValue("/Shield/Regexp", r);
		int g = 0;
		for (int i = 0; i < 8; ++i){
			g = (g << 1) + d->shieldG[i];
		}
		Config::setValue("/Shield/Group", g);
	});
}
开发者ID:LethargicTamias,项目名称:BiliLocal,代码行数:35,代码来源:Shield.cpp


示例20: removeFunction

void Widget::removeFunction()
{
    //! [37]
    QString s = "Montreal";
    s.remove(1, 4);
    // s == "Meal"
    //! [37]

    //! [38]
    QString t = "Ali Baba";
    t.remove(QChar('a'), Qt::CaseInsensitive);
    // t == "li Bb"
    //! [38]

    //! [39]
    QString r = "Telephone";
    r.remove(QRegExp("[aeiou]."));
    // r == "The"
    //! [39]

    //! [96]
    QString r = "Telephone";
    r.remove(QRegularExpression("[aeiou]."));
    // r == "The"
    //! [96]
}
开发者ID:James-intern,项目名称:Qt,代码行数:26,代码来源:main.cpp



注:本文中的QRegularExpression函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QRinput_append函数代码示例发布时间:2022-05-30
下一篇:
C++ QRegExp函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap