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

C++ regExp函数代码示例

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

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



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

示例1: regExp

	ExternalFileDataParser::EFileLineType ExternalFileDataParser::determineLineType(const std::string & line)
	{
		if (line.empty())
		{
			return EFileLineType::EmptyLine;
		}

		if ('#' == line.front())
		{
			return EFileLineType::Comment;
		}

		{
			std::regex regExp("numberOfSamples.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::NumberOfSamples;
			}
		}

		{
			std::regex regExp("samplePeriod.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::SamplePeriod;
			}
		}

		{
			std::regex regExp("description.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::Description;
			}
		}
		
		{
			std::regex regExp("data.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::DataKeyWord;
			}
		}

		if (Utilities::isDouble(line))
		{
			return EFileLineType::Data;
		}

		return EFileLineType::Unknown;
	}
开发者ID:bkozdras,项目名称:DSCRaspberry,代码行数:51,代码来源:ExternalFileDataParser.cpp


示例2: switch

bool auxiliary::regExp(const char* R, const char* C)
{
  if (*R=='*' && *(R+1)==0) 
  {
    return true;
  }
  if (*C==0)
  {
    return *R==0; 
  }
  
  switch(*R) { 
    case 0: 
      return false;
    
    case '\\':
      return *(++R)==*C ? regExp(++R, ++C) : false;
  
    case '!':
      return *(++R)!=*C ? regExp(++R, ++C) : false;
      
    case '~':
      return *(++R)!=*C ? regExp(R+1, C) || regExp(R+1, C+1) : false;
      
    case '?': 
      return regExp(++R, ++C);
    
    case '*': 
      return regExp(R+1,C) || regExp(R,C+1 );

    default:
      return (*R)==(*C) ? regExp(++R, ++C) : false;
  }
}
开发者ID:rikanov,项目名称:Rubik-Dev,代码行数:34,代码来源:auxiliary.cpp


示例3: while

QString DiffAnalystWindow::getNextDiffSessionName()
{
	QString defaultName = "Untitled-";
	int counter = 1;
	QStringList nameList;
	QString ret = "";

	QWidgetList wl = m_pWs->windowList(QWorkspace::CreationOrder);
	QWidgetList::iterator it = wl.begin();
	QWidgetList::iterator end = wl.end();
	for( ; it != end ; it++)
	{
		nameList.push_back( (*it)->name() );
	}

	while(1)
	{
		QString pattern = QString("^")+ defaultName + QString::number(counter) + "$";
		QRegExp regExp(pattern);
		if(nameList.grep(regExp).size() == 0)
		{
			ret = defaultName + QString::number(counter);
			break;
		}else{
			counter++;
		}
	}
	return ret;	
}
开发者ID:concocon,项目名称:CodeAnalyst-3_4_18_0413-Public,代码行数:29,代码来源:DiffAnalystWindow.cpp


示例4: QDialog

IGPrecisionDialog::IGPrecisionDialog(QWidget* parent):
    QDialog(parent)
{
    setupUi(this);
    QRegExp regExp("[1-9][0-9]{0,1}");
    lineEdit->setValidator( new QRegExpValidator(regExp, this) );
}
开发者ID:CraigCasey,项目名称:OpenStudio,代码行数:7,代码来源:IGPrecisionDialog.cpp


示例5: QDialog

Style_Edit::Style_Edit(QWidget *parent, QWidget *dwFrom)
   : QDialog(parent), ui(new Ui::Style_Edit)
{
   ui->setupUi(this);
   m_dwFrom = dwFrom;

   QRegExp regExp(".(.*)\\+?Style");
   QString defaultStyle = QApplication::style()->metaObject()->className();

   if (regExp.exactMatch(defaultStyle)) {
      defaultStyle = regExp.cap(1);
   }

   // 1
   ui->styleCombo->addItems(QStyleFactory::keys());
   ui->styleCombo->setCurrentIndex(ui->styleCombo->findText(defaultStyle, Qt::MatchContains));

   // 2
   ui->styleSheetCombo->setCurrentIndex(ui->styleSheetCombo->findText(Style_Edit::qssName));

   QString styleSheet = this->readStyleSheet(Style_Edit::qssName);
   ui->styleTextEdit->setPlainText(styleSheet);
   ui->applyPB->setEnabled(false);

   // signal
   connect(ui->closePB, SIGNAL(clicked()), this, SLOT(actionClose()));
}
开发者ID:wpbest,项目名称:copperspice,代码行数:27,代码来源:style_edit.cpp


示例6: regExp

QSObject QSRegExpClass::fetchValue( const QSObject *objPtr,
				    const QSMember &mem ) const
{
    if ( mem.type() != QSMember::Custom )
	return QSWritableClass::fetchValue( objPtr, mem );

    QRegExp *re = regExp( objPtr );
    switch ( mem.index() ) {
    case Valid:
	return createBoolean( re->isValid() );
    case Empty:
	return createBoolean( re->isEmpty() );
    case MLength:
	return createNumber( re->matchedLength() );
    case Source:
	return createString( source(objPtr) );
    case Global:
	return createBoolean( isGlobal(objPtr) );
    case IgnoreCase:
	return createBoolean( isIgnoreCase(objPtr) );
    case CTexts: {
 	QSArray array( env() );
 	QStringList ct = re->capturedTexts();
 	QStringList::ConstIterator it = ct.begin();
 	int i = 0;
 	for ( ; it != ct.end(); ++it, ++i )
 	    array.put( QString::number( i ), createString( *it ) );
	array.put( QString::fromLatin1("length"), createNumber( i ) );
 	return array;
    }
    default:
	return createUndefined();
    }
}
开发者ID:AliYousuf,项目名称:pdfedit-ng-,代码行数:34,代码来源:qsregexp_object.cpp


示例7: trcFile

QStringList PluginGame5GraphDialog::parseTrace()
{
	QFile trcFile(getTraceFile());
	QString trcString;
	if (trcFile.open(QIODevice::ReadOnly))
	{
		trcString = QString(trcFile.readAll());
	}

	int begin = trcString.indexOf("SB");
	int end   = trcString.indexOf("SEN", begin + 2);
	QString trcStringS;
	trcStringS = trcString.mid(begin + 2, end - begin - 2);

	QRegExp regExp("(STN|STR)(((\\s)-?\\d{1,5}){8}((\\s)(\\s)(\\d{1,2})(\\s)(\\d{1,2})))(((\\nSRK)((\\s)\\d){4})(\\s\\d{1,2})((\\nSRK)((\\s)\\d){3})(\\s\\d{1,2}))?");
	QStringList list;
	int pos=0;
	while((pos = regExp.indexIn(trcStringS, pos))!= -1)
	{
		list << regExp.cap(2) + regExp.cap(16) + regExp.cap(21);
		pos += regExp.matchedLength();
	}
	trcFile.close();
	return list;
}
开发者ID:cerevra,项目名称:rdo_studio,代码行数:25,代码来源:plugin_game5_graph_dialog.cpp


示例8: regExp

bool rspfDtedInfo::open(const rspfFilename& file)
{
   bool result = false;

   // Test for extension, like dt0, dt1...
   rspfString ext = file.ext();
   rspfRegExp regExp("^[d|D][t|T][0-9]");
   
   if ( regExp.find( ext.c_str() ) )
   {
      rspfDtedVol vol(file, 0);
      rspfDtedHdr hdr(file, vol.stopOffset());
      rspfDtedUhl uhl(file, hdr.stopOffset());
      rspfDtedDsi dsi(file, uhl.stopOffset());
      rspfDtedAcc acc(file, dsi.stopOffset());
      
      //---
      // Check for errors.  Must have uhl, dsi and acc records.  vol and hdr
      // are for magnetic tape only; hence, may or may not be there.
      //---
      if ( (uhl.getErrorStatus() == rspfErrorCodes::RSPF_OK) &&
           (dsi.getErrorStatus() == rspfErrorCodes::RSPF_OK) &&
           (acc.getErrorStatus() == rspfErrorCodes::RSPF_OK) )
      {
         theFile = file;
         result = true;
      }
      else
      {
         theFile.clear();
      }
   }

   return result;
}
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:35,代码来源:rspfDtedInfo.cpp


示例9: QDialog

EditUserDlg::EditUserDlg(int iType,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EditUserDlg)
{
    ui->setupUi(this);

    QPalette palette;
    palette.setColor(QPalette::Background, QColor(224,237,254));
    setPalette(palette);
    //setWindowOpacity(0.95);

    QRegExp regExp("[0-9A-Za-z_]*");
    QValidator *validator = new QRegExpValidator(regExp, this);
    ui->edit_password->setValidator(validator);
    ui->edit_password->setToolTip(tr("有效字符:A-Z,a-z,0-9,_"));

    ui->edit_name->setValidator(validator);
    ui->edit_name->setToolTip(tr("有效字符:A-Z,a-z,0-9,_"));


    ui->label_confirm->hide();
    ui->edit_confirm->hide();

    setFixedSize(size());
    iOpenType = iType; //-1标示新建,大于等于0的数表示打开属性修改
    setWindowTitle(tr("用户属性"));
    ui->edit_name->setFocus();
    init();
}
开发者ID:maqiangddb,项目名称:pc_code,代码行数:29,代码来源:edituserdlg.cpp


示例10: if

void SearchView::executeRequestFromIndex(int index)
{
    SearchViewItem *it = (SearchViewItem*)mWidgets.at(index);

    if (index <= mGoogleSearch.count())
    {
        QString url = mServices.value("Google").arg(it->getText());
        Application::getWindow()->getWebContainer()->getWebView()->load(QUrl(url));

        this->hide();
    }
    else if (index <= mGoogleSearch.count() + mServices.keys().count() + 2)
    {
        QRegExp regExp("\".*\" on (.*)");
        if (regExp.exactMatch(it->getText()))
        {
            QString url = mServices.value(regExp.capturedTexts().at(1)).arg(mWord);
            Application::getWindow()->getWebContainer()->getWebView()->load(QUrl(url));

            this->hide();
        }
    }
    else
    {
        Application::getWindow()->getWebContainer()->getWebView()->findText("", QWebPage::HighlightAllOccurrences);
        Application::getWindow()->getWebContainer()->getWebView()->findText(mWord, QWebPage::HighlightAllOccurrences);

        this->hide();
    }
}
开发者ID:s-faychatelard,项目名称:Helm,代码行数:30,代码来源:searchview.cpp


示例11: i18n

void KFindDialog::slotOk()
{
    // Nothing to find?
    if (pattern().isEmpty())
    {
        KMessageBox::error(this, i18n("You must enter some text to search for."));
        return;
    }

    if (m_regExp->isChecked())
    {
        // Check for a valid regular expression.
        TQRegExp regExp(pattern());

        if (!regExp.isValid())
        {
            KMessageBox::error(this, i18n("Invalid regular expression."));
            return;
        }
    }
    m_find->addToHistory(pattern());
    emit okClicked();
    if ( testWFlags( WShowModal ) )
        accept();
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:25,代码来源:kfinddialog.cpp


示例12: regExp

void MainWindow::filter_topics( const QString & text ) {
    QRegExp regExp(text);
    topicFilter->setDynamicSortFilter(true);
    topicFilter->setFilterKeyColumn(1);
    topicFilter->setFilterRegExp(regExp);
    topicFilter->setFilterCaseSensitivity(Qt::CaseInsensitive);
}
开发者ID:lusaisai,项目名称:myWeb0.2,代码行数:7,代码来源:mainwindow.cpp


示例13: regExp

FormationData::FormationData(QString data)
{
    QStringList temp;
    temp = data.split("=");
    index = temp[0].toInt();
    data = temp[1];
    QRegExp regExp("[(][-]?[0-9]*\\.?[0-9]*,[-]?[0-9]*\\.?[0-9]*[)]");
    if(regExp.indexIn(data)!=-1)
    {
        QString t = regExp.cap(0);
        data = data.mid(t.length());
        ball.x = t.mid(1,t.indexOf(",")-1).toDouble();
        t = t.mid(t.indexOf(",")+1);
        t = t.mid(0,t.length()-1);
        ball.y = t.toDouble();
    }
    while(regExp.indexIn(data)!=-1)
    {
        QString t = regExp.cap(0);
        data = data.mid(t.length());
        Vector2D vec;
        vec.x = t.mid(1,t.indexOf(",")-1).toDouble();
        t = t.mid(t.indexOf(",")+1);
        t = t.mid(0,t.indexOf(")"));
        vec.y = t.toDouble();
        robots.append(vec);
    }
}
开发者ID:KN2C,项目名称:KN2C-SSL,代码行数:28,代码来源:formationdata.cpp


示例14: regExp

QString ParentFolderMethod::rename(QString path, QString fileName, QString query, bool caseSensitive, QString renameString)
{
    const QString format = "<p(\\d*)>";
    QRegExp regExp(format);
    regExp.setCaseSensitivity(Qt::CaseInsensitive);
    int pos = 0;
    pos = regExp.indexIn(fileName, pos);
    if(pos == -1) return fileName;

    int hierarchy = 1;
    /*遡る階層数を決定*/
    if(regExp.cap(1) != ""){
        hierarchy = regExp.cap(1).toInt();
    }

    QString parentPath = path;
    for (int i = 0; i < hierarchy - 1; i++){
        parentPath += QDir::separator() + QString("..");
    }

    QString parentFolder;
    QDir dir(QDir(parentPath).canonicalPath());
    if(dir.exists()){
        parentFolder = dir.dirName();
    } else {
        //親フォルダが存在しない場合は空文字を返す
        parentFolder = "";
    }

    QString renamed = fileName;
    renamed.replace(QRegExp(regExp.cap(0)), parentFolder);

    // 同一置換文字列内に複数の<f>リテラルがあった場合に対処するため、再帰処理にする。
    return rename(path, renamed, query, caseSensitive, renameString);
}
开发者ID:eighttails,项目名称:bRenamer,代码行数:35,代码来源:parentfoldermethod.cpp


示例15: QDialog

GMCharTools::GMCharTools(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GMCharTools)
{
    ui->setupUi(this);

    addCBills = 0;
    addXP = 0;

//    QRegExp regExp("[0-9]{0,}[.][0-9]{1,2}");
    QRegExp regExp("[0-9]{0,}");
    ui->ToMoneyAddGm->setValidator(new QRegExpValidator(regExp,this));
    ui->FromMoneyAddGm->setValidator(new QRegExpValidator(regExp,this));
    QRegExp regExpXP("[0-9]{0,}");
    ui->XPAddGM->setValidator(new QRegExpValidator(regExpXP,this));

//    double a = 12345.12;
//    double b = 54321.12;
//    double c;

//    c = a*b;

//    QString str;
//    str = QVariant(c).toString();

//    qDebug() << str;
}
开发者ID:TCArknight,项目名称:Battletech-Character-Creator,代码行数:27,代码来源:gmchartools.cpp


示例16: xmlQuery

QList<QString>
CXParamData::getImages(const QString& aFileName, const QString& aType)
{
  QList<QString> res;

  QXmlQuery xmlQuery(QXmlQuery::XQuery10);
  xmlQuery.setQuery(
      QString("doc('%1')/Settings/ui-TechParams/%2/assembly").arg(aFileName).arg(
          aType));

  if (!xmlQuery.isValid())
    return res;

  QString text;
  if (xmlQuery.evaluateTo(&text))
    {
      QRegExp regExp("<item +path=\"([^\"]+)\"[^>]*/>");
      regExp.setMinimal(true);

      int index = regExp.indexIn(text);
      while (index >= 0)
        {
          res.append(regExp.cap(1));

          index += regExp.matchedLength();
          index = regExp.indexIn(text, index);
        }
    }

  return res;
}
开发者ID:superkulpa,项目名称:phx-cnc-ui,代码行数:31,代码来源:CXParamData.cpp


示例17: regExp

QString VPreviewManager::fetchImageUrlToPreview(const QString &p_text, int &p_width, int &p_height)
{
    QRegExp regExp(VUtils::c_imageLinkRegExp);

    p_width = p_height = -1;

    int index = regExp.indexIn(p_text);
    if (index == -1) {
        return QString();
    }

    int lastIndex = regExp.lastIndexIn(p_text);
    if (lastIndex != index) {
        return QString();
    }

    QString tmp(regExp.cap(7));
    if (!tmp.isEmpty()) {
        p_width = tmp.toInt();
        if (p_width <= 0) {
            p_width = -1;
        }
    }

    tmp = regExp.cap(8);
    if (!tmp.isEmpty()) {
        p_height = tmp.toInt();
        if (p_height <= 0) {
            p_height = -1;
        }
    }

    return regExp.cap(2).trimmed();
}
开发者ID:getwindow,项目名称:vnote,代码行数:34,代码来源:vpreviewmanager.cpp


示例18: QDialog

TypeDocForm::TypeDocForm(QString id, QWidget *parent, bool onlyForRead) :
    QDialog(parent)
{
    exchangeFile.setFileName("Message.txt");
    if(!exchangeFile.isOpen()){
        exchangeFile.open(QIODevice::ReadWrite);
    }

    indexTemp = id;

    QFile file(":/ToolButtonStyle.txt");
    file.open(QFile::ReadOnly);
    //QString styleSheetString = QLatin1String(file.readAll());

    labelName = new QLabel(trUtf8("Prichina Obuch:"));
    editName = new LineEdit;
    editName->setReadOnly(onlyForRead);
    QRegExp regExp("[\\x0410-\\x044f 0-9 ()\" -]{150}");
    editName->setValidator(new QRegExpValidator(regExp,this));
    labelName->setBuddy(editName);

    savePushButton = new QPushButton(trUtf8("Save"));
    connect(savePushButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    savePushButton->setToolTip(trUtf8("Save And Close Button"));

    cancelPushButton = new QPushButton(trUtf8("Cancel"));
    cancelPushButton->setDefault(true);
    cancelPushButton->setStyleSheet("QPushButton:hover {color: red}");
    connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(accept()));
    cancelPushButton->setToolTip(trUtf8("Cancel Button"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole);

    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("SELECT typedocname FROM typedoc WHERE typedocid = :typedocid");
        query.bindValue(":typedocid",indexTemp);
        query.exec();
        while(query.next()){
            editName->setText(query.value(0).toString());
        }
    }else{
        editName->clear();
    }

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(labelName,0,0);
    mainLayout->addWidget(editName,0,1);
    if(!onlyForRead){
        mainLayout->addWidget(buttonBox,1,1);
        editName->selectAll();
    }

    setLayout(mainLayout);

    setWindowTitle(trUtf8("Type doc"));
    readSettings();
}
开发者ID:AndrewBatrakov,项目名称:EmployeeClient,代码行数:60,代码来源:typedocform.cpp


示例19: throwError

// Shared implementation used by test and exec.
bool RegExpObject::match(ExecState* exec)
{
    RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();

    UString input = !exec->argumentCount() ? regExpConstructor->input() : exec->argument(0).toString(exec);
    if (input.isNull()) {
        throwError(exec, createError(exec, makeString("No input to ", toString(exec), ".")));
        return false;
    }

    if (!regExp()->global()) {
        int position;
        int length;
        regExpConstructor->performMatch(d->regExp.get(), input, 0, position, length);
        return position >= 0;
    }

    if (d->lastIndex < 0 || d->lastIndex > input.length()) {
        d->lastIndex = 0;
        return false;
    }

    int position;
    int length = 0;
    regExpConstructor->performMatch(d->regExp.get(), input, static_cast<int>(d->lastIndex), position, length);
    if (position < 0) {
        d->lastIndex = 0;
        return false;
    }

    d->lastIndex = position + length;
    return true;
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:34,代码来源:RegExpObject.cpp


示例20: throwError

// Shared implementation used by test and exec.
bool RegExpObject::match(ExecState* exec, const ArgList& args)
{
    RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();

    UString input = args.isEmpty() ? regExpConstructor->input() : args.at(0).toString(exec);
    if (input.isNull()) {
        throwError(exec, GeneralError, "No input to " + toString(exec) + ".");
        return false;
    }

    if (!regExp()->global()) {
        int position;
        int length;
        regExpConstructor->performMatch(d->regExp.get(), input, 0, position, length);
        return position >= 0;
    }

    if (d->lastIndex < 0 || d->lastIndex > input.size()) {
        d->lastIndex = 0;
        return false;
    }

    int position;
    int length = 0;
    regExpConstructor->performMatch(d->regExp.get(), input, static_cast<int>(d->lastIndex), position, length);
    if (position < 0) {
        d->lastIndex = 0;
        return false;
    }

    d->lastIndex = position + length;
    return true;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:34,代码来源:RegExpObject.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ regRd函数代码示例发布时间:2022-05-30
下一篇:
C++ reg函数代码示例发布时间: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