本文整理汇总了C++中QRegExp::exactMatch方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExp::exactMatch方法的具体用法?C++ QRegExp::exactMatch怎么用?C++ QRegExp::exactMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegExp
的用法示例。
在下文中一共展示了QRegExp::exactMatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lineIsStackBase
/* This function returns true if the given stack frame line is the base of the backtrace
and thus the parser should not rate any frames below that one. */
static bool lineIsStackBase(const BacktraceLine & line)
{
//optimization. if there is no function name, do not bother to check it
if ( line.rating() == BacktraceLine::MissingEverything
|| line.rating() == BacktraceLine::MissingFunction )
return false;
//this is the base frame for all threads except the main thread
//FIXME that probably works only on linux
if ( line.functionName() == QLatin1String("start_thread") )
return true;
QRegExp regExp;
regExp.setPattern(QStringLiteral("(kde)?main")); //main() or kdemain() is the base for the main thread
if ( regExp.exactMatch(line.functionName()) )
return true;
//HACK for better rating. we ignore all stack frames below any function that matches
//the following regular expression. The functions that match this expression are usually
//"QApplicationPrivate::notify_helper", "QApplication::notify" and similar, which
//are used to send any kind of event to the Qt application. All stack frames below this,
//with or without debug symbols, are useless to KDE developers, so we ignore them.
regExp.setPattern(QStringLiteral("(Q|K)(Core)?Application(Private)?::notify.*"));
if ( regExp.exactMatch(line.functionName()) )
return true;
//attempt to recognize crashes that happen after main has returned (bug 200993)
if ( line.functionName() == QLatin1String("~KCleanUpGlobalStatic") ||
line.functionName() == QLatin1String("~QGlobalStatic") ||
line.functionName() == QLatin1String("exit") ||
line.functionName() == QLatin1String("*__GI_exit") )
return true;
return false;
}
示例2: informationRestrain
bool CPrivateInfo::informationRestrain()
{
QRegExp regExp;
regExp.setPattern("^[A-Za-z][A-Za-z0-9]{2,19}$");
if(!regExp.exactMatch(ui->accountLineEdit->text()))
{
//QMessageBox::critical(this, "Error", "帐号格式错误,请再试一遍");
QMessageBox::critical(this, tr("Error"),
tr("Account's Format is wrong. Please try again"));
return false;
}
if(ui->nicknameLineEdit->text().isEmpty()
|| ui->nicknameLineEdit->text().size() > 40)
{
//QMessageBox::critical(this, "Error", "呢称格式错误,请再试一遍");
QMessageBox::critical(this, tr("Error"),
tr("Nickname's Format is wrong. Please try again"));
return false;
}
regExp.setPattern("(^(\\d{3,4}-)\\d{7,8})$|(1[0-9]{10})");
if(!ui->phoneNumLineEdit->text().isEmpty() &&
!regExp.exactMatch(ui->phoneNumLineEdit->text()))
{
//QMessageBox::critical(this, "Error", "密码格式错误,请再试一遍");
QMessageBox::critical(this, tr("Error"),
tr("Phone number's Format is wrong. Please try again"));
return false;
}
if(!ui->mobileNumLineEdit->text().isEmpty() &&
!regExp.exactMatch(ui->mobileNumLineEdit->text()))
{
//QMessageBox::critical(this, "Error", "密码格式错误,请再试一遍");
QMessageBox::critical(this, tr("Error"),
tr("Mobile number's Format is wrong. Please try again"));
return false;
}
regExp.setPattern("^\\d{4}-\\d{1,2}-\\d{1,2}$");
if( !regExp.exactMatch(ui->birthdayLineEdit->text())
&& !ui->birthdayLineEdit->text().isEmpty())
{
//QMessageBox::critical(this, "Error", "出生日期格式错误,请再试一遍");
QMessageBox::critical(this, tr("Error"),
tr("Birthday's Format is wrong. Please try again"));
return false;
}
if(ui->cityLineEdit->text().size() > 40)
{
QMessageBox::critical(this, tr("Error"),
tr("City's Format is wrong. Please try again"));
return false;
}
if(ui->aboutTextEdit->toPlainText().size() > 400)
{
QMessageBox::critical(this, tr("Error"),
tr("About myself's Format is wrong. Please try again"));
return false;
}
return true;
}
示例3: pasteFile
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void elMundo::pasteFile (QString filename, int atX, int atY)
{
QFile file(filename);
if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
QTextStream in(&file);
setRules(0x8,0xC);
while (! in.atEnd()) {
QString line = in.readLine();
if (line.isEmpty()) continue; // always ignore completely empty lines
else if (line.startsWith('#')) {
if (line.startsWith("#R"))
continue; // TODO: process rules
else if (reCellBlock.exactMatch(line))
pasteStart(atX + reCellBlock.cap(1).toInt(),
atY + reCellBlock.cap(2).toInt());
else if (line.startsWith("#C") || line.startsWith("#C"))
continue; // TODO: keep comments somewhere
}
else if (line.startsWith('!')) { // dblife-style comments
continue; // TODO: keep comments somewhere
}
else if (reRLEstart.exactMatch(line)) {
if (!reRLEstart.cap(3).isEmpty()) setRules(reRLEstart.cap(3).cStr());
pasteStart(atX, atY);
while (!in.atEnd())
if (pasteRLEX_add(in.readLine())) break;
break;
}
else pasteLIFE_add(line);
}
file.close();
}
示例4: sync
bool KSambaSharePrivate::sync()
{
const QRegExp headerRx(QString::fromLatin1("^\\s*\\["
"([^%<>*\?|/\\+=;:\",]+)"
"\\]"));
const QRegExp OptValRx(QString::fromLatin1("^\\s*([\\w\\d\\s]+)"
"="
"(.*)$"));
QTextStream stream(getNetUserShareInfo());
QString currentShare;
QStringList shareList;
while (!stream.atEnd()) {
const QString line = stream.readLine().trimmed();
if (headerRx.exactMatch(line)) {
currentShare = headerRx.cap(1).trimmed();
shareList << currentShare;
if (!data.contains(currentShare)) {
KSambaShareData shareData;
shareData.dd->name = currentShare;
data.insert(currentShare, shareData);
}
} else if (OptValRx.exactMatch(line)) {
const QString key = OptValRx.cap(1).trimmed();
const QString value = OptValRx.cap(2).trimmed();
KSambaShareData shareData = getShareByName(currentShare);
if (key == QLatin1String("path")) {
shareData.dd->path = value;
} else if (key == QLatin1String("comment")) {
shareData.dd->comment = value;
} else if (key == QLatin1String("usershare_acl")) {
shareData.dd->acl = value;
} else if (key == QLatin1String("guest_ok")) {
shareData.dd->guestPermission = value;
} else {
qWarning() << "Something nasty happen while parsing 'net usershare info'"
<< "share:" << currentShare << "key:" << key;
}
} else if (line.trimmed().isEmpty()) {
continue;
} else {
return false;
}
}
QMutableMapIterator<QString, KSambaShareData> i(data);
while (i.hasNext()) {
i.next();
if (!shareList.contains(i.key())) {
i.remove();
}
}
return true;
}
示例5: treatFuncsInt
/*!
* \brief treatFuncs treat the last level of recursion: parenthesis
* \param expr The expression to parse.
* \param noProblem A reference to a bool set to true if no problem happened, false otherwise.
* \return The value of the parsed subexpression or 0 in case of error.
*
* The expression should not contain operators not nested anymore. The subexpressions within parenthesis will be treated by recalling the level 1 function.
*/
double treatFuncsInt(QString const& expr, bool & noProblem)
{
noProblem = true;
QRegExp funcExpInteger = funcExprInteger;
QRegExp integerExp = integerExpr;
QRegExp numberExp = numberExpr;
if (funcExpInteger.exactMatch(expr.trimmed())) {
int sign = funcExpInteger.capturedTexts()[1].isEmpty() ? 1 : -1;
QString subExpr = funcExpInteger.capturedTexts()[2];
double val = treatLevel1Int(subExpr, noProblem);
if (!noProblem) {
return 0;
}
return sign*val;
} else if(numberExp.exactMatch(expr.trimmed())) {
double value = QVariant(expr).toDouble(&noProblem);
return value;
}
noProblem = false;
return 0;
}
示例6: uriChanged
void ConnectionDialog::uriChanged (const QString& uri)
{
QRegExp serverPortRegExp ("^irc://([a-zA-Z0-9\\.\\-]+):([0-9]+)/(\\S+)$");
QRegExp serverRegExp ("^irc://([a-zA-Z0-9\\.\\-]+)/(\\S+)$");
QString server;
QString room;
if(serverPortRegExp.exactMatch(uri)) {
server = serverPortRegExp.cap(1);
room = serverPortRegExp.cap(3);
} else if(serverRegExp.exactMatch(uri)) {
server = serverRegExp.cap(1);
room = serverRegExp.cap(2);
} else {
serverEdit->setCurrentIndex (-1);
return;
}
int index = serverEdit->findText(server, Qt::MatchFixedString);
if (index >= 0)
serverEdit->setCurrentIndex(index);
else
serverEdit->setEditText(server);
index = roomEdit->findText(room, Qt::MatchFixedString);
if (index >= 0)
roomEdit->setCurrentIndex(index);
else
roomEdit->setEditText(room);
}
示例7: checkValues
int checkValues(QList<QStringList> matrix) {
checkRowLength(matrix); //make sure rows have matching number of columns
bool typeCheck;
isInt = intPattern.exactMatch(matrix[0][0]); //check first number for type
isFloat = floatPattern.exactMatch(matrix[0][0]);
if (!isInt && !isFloat) //handle case where value isn't an int or float
throw "The values used do not match the correct data type.";
for(int i =0; i < matrix.length(); i++) {
for(int j =0; j<matrix[0].length(); j++) {
if (isInt)
typeCheck = intPattern.exactMatch(matrix[i][j]);
if (isFloat)
typeCheck = floatPattern.exactMatch(matrix[i][j]);
if (!typeCheck)
throw "The values used do not match the correct data type.";
}
}
if (isInt)
return 1; //type is int
else if (isFloat)
return 2; //type is float
else
return -1; //something went wrong
}
示例8: insertSequenceToHeader
static void insertSequenceToHeader(QTextBlock p_block,
QRegExp &p_reg,
QRegExp &p_preReg,
const QString &p_seq)
{
if (!p_block.isValid()) {
return;
}
QString text = p_block.text();
bool matched = p_reg.exactMatch(text);
Q_ASSERT(matched);
matched = p_preReg.exactMatch(text);
Q_ASSERT(matched);
int start = p_reg.cap(1).length() + 1;
int end = p_preReg.cap(1).length();
Q_ASSERT(start <= end);
QTextCursor cursor(p_block);
cursor.setPosition(p_block.position() + start);
if (start != end) {
cursor.setPosition(p_block.position() + end, QTextCursor::KeepAnchor);
}
if (p_seq.isEmpty()) {
cursor.removeSelectedText();
} else {
cursor.insertText(p_seq + ' ');
}
}
示例9: slotJobExited
void EditorsDialog::slotJobExited( bool normalExit, int exitStatus )
{
if (!normalExit)
{
KMessageBox::sorry( this, i18n("Log failed with exitStatus == %1").arg( exitStatus), i18n("Log Failed") );
return;
}
static QRegExp re("([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s"
"([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s(.*)");
static QRegExp subre("([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s"
"([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s(.*)");
QString lastfilename;
QStringList lines = QStringList::split( "\n", m_output );
int found = 0;
for (size_t i=0; i<lines.count(); ++i) {
QString s = lines[i].simplifyWhiteSpace();
kdDebug(9006) << "editors:---" << s << "---" << endl;
kdDebug(9006) << " : lastfile was " << lastfilename << endl;
if (re.exactMatch(s)) {
QString file = re.cap( 1 );
QString locker = re.cap( 2 );
QString date = re.cap(5)+" "+re.cap(4)+" "+re.cap(7)+" "+re.cap(6);
m_textBrowser->append( "<b>"+i18n("File")+": <code>"+file+"</code></b>" );
m_textBrowser->append( "<b>"+i18n("User")+":</b> "+locker );
m_textBrowser->append( "<b>"+i18n("Date")+":</b> "+date );
m_textBrowser->append( "<hr>" );
found++;
lastfilename = file;
} else {
if (subre.exactMatch(s)) {
QString file = lastfilename;
QString locker = subre.cap( 1 );
QString date = subre.cap(4)+" "+subre.cap(3)+" "+subre.cap(6)+" "+subre.cap(5);
m_textBrowser->append( "<b>"+i18n("File")+": <code>"+file+"</code></b>" );
m_textBrowser->append( "<b>"+i18n("User")+":</b> "+locker );
m_textBrowser->append( "<b>"+i18n("Date")+":</b> "+date );
m_textBrowser->append( "<hr>" );
found++;
}
}
}
if (!found)
m_textBrowser->append(i18n("No files from your query are marked as being edited."));
m_textBrowser->source();
if (m_cvsJob) {
disconnectDCOPSignal( m_cvsJob->app(), m_cvsJob->obj(), "jobExited(bool, int)", "slotJobExited(bool, int)" );
delete m_cvsJob;
m_cvsJob=NULL;
}
}
示例10: parseOutput
void CvsLogJob::parseOutput(const QString& jobOutput, QList<QVariant>& events)
{
static QRegExp rx_sep( "[-=]+" );
static QRegExp rx_rev( "revision ((\\d+\\.?)+)" );
static QRegExp rx_branch( "branches:\\s+(.*)" );
static QRegExp rx_date( "date:\\s+([^;]*);\\s+author:\\s+([^;]*).*" );
QStringList lines = jobOutput.split('\n');
KDevelop::VcsEvent item;
bool firstSeperatorReached = false;
QString log;
for (int i=0; i<lines.count(); ++i) {
QString s = lines[i];
// qCDebug(PLUGIN_CVS) << "line:" << s ;
if (rx_rev.exactMatch(s)) {
// qCDebug(PLUGIN_CVS) << "MATCH REVISION" ;
KDevelop::VcsRevision rev;
rev.setRevisionValue( rx_rev.cap(1), KDevelop::VcsRevision::FileNumber );
item.setRevision( rev );
} else if (rx_branch.exactMatch(s)) {
// qCDebug(PLUGIN_CVS) << "MATCH BRANCH" ;
} else if (rx_date.exactMatch(s)) {
// qCDebug(PLUGIN_CVS) << "MATCH DATE" ;
QString date = rx_date.cap(1);
// cut out the part that matches the Qt::ISODate format
date.truncate(19);
item.setDate( QDateTime::fromString( date, Qt::ISODate ) );
item.setAuthor( rx_date.cap(2) );
} else if (rx_sep.exactMatch(s)) {
// qCDebug(PLUGIN_CVS) << "MATCH SEPARATOR" ;
if (firstSeperatorReached) {
item.setMessage( log );
log.clear();
events.append( qVariantFromValue( item ) );
KDevelop::VcsEvent empty;
item = empty;
} else {
firstSeperatorReached = true;
}
} else {
if (firstSeperatorReached) {
// qCDebug(PLUGIN_CVS) << "ADDING LOG" ;
log += s+'\n';
}
}
}
}
示例11: processString
bool processString(const QString &WLine_) {
if(m_VariableWithValue.exactMatch(WLine_)) {
m_Parameters.Variables.insert(m_VariableWithValue.cap(1), m_VariableWithValue.cap(2));
return true;
}
if(m_VariableWithoutValue.exactMatch(WLine_)) {
m_Parameters.Variables.insert(m_VariableWithValue.cap(0), QString());
return true;
}
return false;
}
示例12: slotJobExited
void CVSLogPage::slotJobExited( bool normalExit, int exitStatus )
{
// m_part->core()->running( m_part, false );
if (!normalExit)
{
KMessageBox::sorry( this, i18n("Log failed with exitStatus == %1").arg( exitStatus), i18n("Log Failed") );
return;
}
static QRegExp rx_sep( "\\-+" );
static QRegExp rx_sep2( "=+" );
static QRegExp rx_date( "date: .* author: .* state: .* lines: .*" );
// "revision" followed by one or more decimals followed by a optional dot
static QRegExp rx_rev( "revision ((\\d+\\.?)+)" );
m_textBrowser->setTextFormat( QTextBrowser::PlainText );
for (size_t i=0; i<m_diffStrings.count(); ++i) {
QString s = m_diffStrings[i];
kdDebug(9006) << "Examining line: " << s << endl;
if ( rx_rev.exactMatch(s) )
{
QString ver = rx_rev.cap( 1 );
QString dstr = "<b>" + s + "</b> ";
int lastVer = ver.section( '.', -1 ).toInt() - 1;
if ( lastVer > 0 ) {
QString lv = ver.left( ver.findRev( "." ) + 1 ) + QString::number( lastVer );
dstr += " [<a href=\"diff:/" + m_pathName + "/" + lv + "_" + ver + "\">diff to " + lv + "</a>]";
}
m_textBrowser->setTextFormat( QTextBrowser::RichText );
m_textBrowser->append( dstr );
m_textBrowser->setTextFormat( QTextBrowser::PlainText );
}
else if ( rx_date.exactMatch(s) )
{
m_textBrowser->setTextFormat( QTextBrowser::RichText );
m_textBrowser->append( "<i>" + s + "</i>" );
m_textBrowser->setTextFormat( QTextBrowser::PlainText );
}
else if ( rx_sep.exactMatch(s) || rx_sep2.exactMatch(s) )
{
m_textBrowser->append( "\n" );
m_textBrowser->setTextFormat( QTextBrowser::RichText );
m_textBrowser->append( "<hr>" );
m_textBrowser->setTextFormat( QTextBrowser::PlainText );
} else
{
m_textBrowser->append( s );
}
}
m_logTextBackup = m_textBrowser->source();
// emit jobFinished( normalExit, exitStatus );
}
示例13: comment
QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const QString& line)
{
QString text = line.simplified();
// comment line: # comment
static QRegExp comment("\\#.*");
// title line: keyboard "title"
static QRegExp title("keyboard\\s+\"(.*)\"");
// key line: key KeySequence : "output"
// key line: key KeySequence : command
static QRegExp key("key\\s+([\\w\\+\\s\\-]+)\\s*:\\s*(\"(.*)\"|\\w+)");
QList<Token> list;
if ( text.isEmpty() || comment.exactMatch(text) )
{
return list;
}
if ( title.exactMatch(text) )
{
Token titleToken = { Token::TitleKeyword , QString() };
Token textToken = { Token::TitleText , title.capturedTexts()[1] };
list << titleToken << textToken;
}
else if ( key.exactMatch(text) )
{
Token keyToken = { Token::KeyKeyword , QString() };
Token sequenceToken = { Token::KeySequence , key.capturedTexts()[1].remove(' ') };
list << keyToken << sequenceToken;
if ( key.capturedTexts()[3].isEmpty() )
{
// capturedTexts()[2] is a command
Token commandToken = { Token::Command , key.capturedTexts()[2] };
list << commandToken;
}
else
{
// capturedTexts()[3] is the output string
Token outputToken = { Token::OutputText , key.capturedTexts()[3] };
list << outputToken;
}
}
else
{
kWarning() << "Line in keyboard translator file could not be understood:" << text;
}
return list;
}
示例14: IsFiltered
bool DatabaseGroupWidget::IsFiltered()
{
if(Filter.isEmpty())
return false;
QRegExp Regexp;
Regexp.setPatternSyntax(QRegExp::Wildcard);
Regexp.setPattern("*" + Filter + "*");
Regexp.setCaseSensitivity(Qt::CaseInsensitive);
return !(Regexp.exactMatch(GetName()) || Regexp.exactMatch(GetDescription()));
}
示例15: doubleRe
// TODO: RegExp is still a simple hack
//
QValidator::State
EngNumberValidator::validate( QString & input, int & pos ) const
{
static QRegExp doubleRe( "-?\\d+\\.?\\d*" );
static QRegExp fullRe( "-?\\d+\\.?\\d*[munpkMGT]?" );
input = input.stripWhiteSpace();
pos = QMIN( (int)input.length(), pos );
if (fullRe.exactMatch( input )) return Acceptable;
if (doubleRe.exactMatch( input )) return Intermediate;
return Invalid;
}