当前位置: 首页>>代码示例>>C++>>正文


C++ QRegExp::lastIndexIn方法代码示例

本文整理汇总了C++中QRegExp::lastIndexIn方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExp::lastIndexIn方法的具体用法?C++ QRegExp::lastIndexIn怎么用?C++ QRegExp::lastIndexIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QRegExp的用法示例。


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

示例1: extractDistinguisher

QString extractDistinguisher(const QString& name)
{
    static QRegExp distinguisher(" \\([a-z0-9 \\-\\(\\)]+\\)");
    distinguisher.lastIndexIn(name);
    
    return distinguisher.cap(0);
}
开发者ID:kirjs,项目名称:tangomatcher,代码行数:7,代码来源:utils.cpp

示例2: changeGivenUrlIfDocumentExists

void PairwiseAlignmentHirschbergTask::changeGivenUrlIfDocumentExists(QString & givenUrl, const Project * curProject) {
    if(NULL != curProject->findDocumentByURL(GUrl(givenUrl))) {
        for(size_t i = 1; ; i++) {
            QString tmpUrl = givenUrl;
            QRegExp dotWithExtensionRegExp ("\\.{1,1}[^\\.]*$|^[^\\.]*$");
            dotWithExtensionRegExp.lastIndexIn(tmpUrl);
            tmpUrl.replace(dotWithExtensionRegExp.capturedTexts().last(), "(" + QString::number(i) + ")" + dotWithExtensionRegExp.capturedTexts().last());
            if(NULL == curProject->findDocumentByURL(GUrl(tmpUrl))) {
                givenUrl = tmpUrl;
                break;
            }
        }
    }
}
开发者ID:ugeneunipro,项目名称:ugene-old,代码行数:14,代码来源:PairwiseAlignmentHirschbergTask.cpp

示例3: completionRange

Range CodeCompletionModelControllerInterface::completionRange(View* view, const Cursor &position)
{
    Cursor end = position;

    QString text = view->document()->line(end.line());

    static QRegExp findWordStart( "\\b([_\\w]+)$" );
    static QRegExp findWordEnd( "^([_\\w]*)\\b" );

    Cursor start = end;

    if (findWordStart.lastIndexIn(text.left(end.column())) >= 0)
        start.setColumn(findWordStart.pos(1));

    if (findWordEnd.indexIn(text.mid(end.column())) >= 0)
        end.setColumn(end.column() + findWordEnd.cap(1).length());

    //kDebug()<<"returning:"<<Range(start,end);
    return Range(start, end);
}
开发者ID:ktuan89,项目名称:kate-4.8.0,代码行数:20,代码来源:codecompletionmodelcontrollerinterface.cpp

示例4: findInBlock

static bool findInBlock(QTextDocument *doc, const QTextBlock &block, const QRegExp &expr, int offset,
                        QTextDocument::FindFlags options, QTextCursor &cursor)
{
    QString text = block.text();
    if(options & QTextDocument::FindBackward)
        text.truncate(offset);
    text.replace(QChar::Nbsp, QLatin1Char(' '));

    int idx = -1;
    while (offset >=0 && offset <= text.length()) {
        idx = (options & QTextDocument::FindBackward) ?
               expr.lastIndexIn(text, offset) : expr.indexIn(text, offset);
        if (idx == -1)
            return false;

        if (options & QTextDocument::FindWholeWords) {
            const int start = idx;
            const int end = start + expr.matchedLength();
            if ((start != 0 && text.at(start - 1).isLetterOrNumber())
                || (end != text.length() && text.at(end).isLetterOrNumber())) {
                //if this is not a whole word, continue the search in the string
                offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1;
                idx = -1;
                continue;
            }
        }
        //we have a hit, return the cursor for that.
        break;
    }

    if (idx == -1)
        return false;

    cursor = QTextCursor(doc);
    cursor.setPosition(block.position() + idx);
    cursor.setPosition(cursor.position() + expr.matchedLength(), QTextCursor::KeepAnchor);
    return true;
}
开发者ID:ARTisERR0R,项目名称:supercollider,代码行数:38,代码来源:editor.cpp

示例5: initAacEncImpl

void InitAacEncTask::initAacEncImpl(const char *const toolName, const char *const fileNames[], const quint32 &toolMinVersion, const quint32 &verDigits, const quint32 &verShift, const char *const verStr, QRegExp &regExpVer, QRegExp &regExpSig)
{
	static const size_t MAX_FILES = 8;
	const QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
	
	QFileInfoList fileInfo;
	for(size_t i = 0; fileNames[i] && (fileInfo.count() < MAX_FILES); i++)
	{
		fileInfo.append(QFileInfo(QString("%1/%2").arg(appPath, QString::fromLatin1(fileNames[i]))));
	}
	
	for(QFileInfoList::ConstIterator iter = fileInfo.constBegin(); iter != fileInfo.constEnd(); iter++)
	{
		if(!(iter->exists() && iter->isFile()))
		{
			qDebug("%s encoder binaries not found -> Encoding support will be disabled!\n", toolName);
			return;
		}
		if((iter->suffix().compare("exe", Qt::CaseInsensitive) == 0) && (!MUtils::OS::is_executable_file(iter->canonicalFilePath())))
		{
			qDebug("%s executable is invalid -> %s support will be disabled!\n", MUTILS_UTF8(iter->fileName()), toolName);
			return;
		}
	}

	qDebug("Found %s encoder binary:\n%s\n", toolName, MUTILS_UTF8(fileInfo.first().canonicalFilePath()));

	//Lock the encoder binaries
	QScopedPointer<LockedFile> binaries[MAX_FILES];
	try
	{
		size_t index = 0;
		for(QFileInfoList::ConstIterator iter = fileInfo.constBegin(); iter != fileInfo.constEnd(); iter++)
		{
			binaries[index++].reset(new LockedFile(iter->canonicalFilePath()));
		}
	}
	catch(...)
	{
		qWarning("Failed to get excluive lock to encoder binary -> %s support will be disabled!", toolName);
		return;
	}

	QProcess process;
	MUtils::init_process(process, fileInfo.first().absolutePath());

	process.start(fileInfo.first().canonicalFilePath(), QStringList() << "-help");

	if(!process.waitForStarted())
	{
		qWarning("%s process failed to create!", toolName);
		qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData());
		process.kill();
		process.waitForFinished(-1);
		return;
	}

	quint32 toolVersion = 0;
	bool sigFound = regExpSig.isEmpty() ? true : false;

	while(process.state() != QProcess::NotRunning)
	{
		if(!process.waitForReadyRead())
		{
			if(process.state() == QProcess::Running)
			{
				qWarning("%s process time out -> killing!", toolName);
				process.kill();
				process.waitForFinished(-1);
				return;
			}
		}
		while(process.canReadLine())
		{
			QString line = QString::fromUtf8(process.readLine().constData()).simplified();
			if((!sigFound) && regExpSig.lastIndexIn(line) >= 0)
			{
				sigFound = true;
				continue;
			}
			if(sigFound && (regExpVer.lastIndexIn(line) >= 0))
			{
				quint32 tmp[8];
				if(MUtils::regexp_parse_uint32(regExpVer, tmp, qMin(verDigits, 8U)))
				{
					toolVersion = 0;
					for(quint32 i = 0; i < verDigits; i++)
					{
						toolVersion = (toolVersion * verShift) + qBound(0U, tmp[i], (verShift - 1));
					}
				}
			}
		}
	}

	if(toolVersion <= 0)
	{
		qWarning("%s version could not be determined -> Encoding support will be disabled!", toolName);
		return;
	}
//.........这里部分代码省略.........
开发者ID:wyrover,项目名称:LameXP,代码行数:101,代码来源:Thread_Initialization.cpp


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