[Qt-interest] Problem with qregexpr
Sean Harmer
sean.harmer at maps-technology.com
Mon Oct 5 14:39:32 CEST 2009
Hi,
On Monday 05 Oct 2009 13:28:26 matteo wrote:
> No error occured with errorString() and it doesn't match with
> QRegExp("^(--\\s*STRING)$").
The following works for me:
#include <QDebug>
#include <QRegExp>
int main( int argc, char* argv[] )
{
QString s( "--STRING" );
QRegExp rx1( "^(--\\s*STRING)$" );
if ( rx1.indexIn( s ) != -1 )
{
qDebug() << "The regexp" << rx1.pattern() << "matches";
qDebug() << "The captured text is" << rx1.cap( 1 );
}
else
{
qDebug() << "The regexp" << rx1.pattern() << "did not match";
}
}
I get the following output:
The regexp "^(--\s*STRING)$" matches
The captured text is "--STRING"
How are you using QRegExp?
Sean
More information about the Qt-interest-old
mailing list