Compound list   File list   Header files   Compound Members   File Members  

QaRegExp Class Reference

Matches Regular Expressions against strings. More...

#include <qaregexp.hpp>

List of all members.

Public Members


Detailed Description

Matches Regular Expressions against strings.

Warning:
This version does not support unicode strings, they are converted to ascii before being used.

This class uses the system calls reg_comp and reg_exec, see the man pages for regex for more information on regular expressions.

Example:

  // Match for <text> = <text>
  QaRegExp reg( "([a-zA-Z]+)[ \t]*=[ \t]*([a-zA-Z]+)" );

  // Now match the string
  if ( reg.match( "RegExpTest = True" ) )
  {
      QaRegExpMatch m = reg.matches();

      // Now print out all matches
      for ( QStringList::ConstIterator it = m.toString().begin(); it != m.toString().end(); ++it )
      {
          qDebug( "\"%s\"", (*it).ascii() );
      }
  }

  // Or use it like this
  if ( reg.match( "RegExpTest = True", 2 ) )
      qDebug( "%s", reg.matchString( 2 ).ascii() );


Member Function Documentation

QaRegExp::QaRegExp( const QString &r, bool c = true )

Creates a regexp query.

Parameters:
r - The string to use for regular expression matching.
c - True means match case sensitive.

QaRegExp::QaRegExp( const QaRegExp &r )

virtual QaRegExp::~QaRegExp() [virtual]

Destroys the object

bool QaRegExp::caseSensitive() const

Returns:
True if matching is done case sensitive.

void QaRegExp::setCaseSensitive( bool s )

Sets the case sensitivity flag.

bool QaRegExp::match( const QString &s, int sub = 0 )

Matches a string against the regexp on the given sub expression.

Parameters:
s - The string to match on.
sub - Which sub expression should be checked, 0 is default and means the whole regexp.
Returns:
True if the subexpression matched.

int QaRegExp::matchMultiple( const QString &s, int sub = 0 )

Matches a string against the regexp on the given sub expression, will match as many times as possible and extracting the wanted subexpression every time it matches.

Parameters:
s - The string to match on.
sub - Which sub expression should be checked, 0 is default and means the whole regexp.
Returns:
Number of matches.

QString QaRegExp::matchString( int sub = 0 )

Returns:
The string that matched the sub expression.

QStringList QaRegExp::matchStrings()

Returns:
A list of sub expression strings.

int QaRegExp::matchBeginning( int sub = 0 ) const

Returns:
The start offset of the matched sub expression.

int QaRegExp::matchEnd( int sub = 0 ) const

Returns:
The start offset of the matched sub expression.

const QaRegExpMatch& QaRegExp::matches() const

Returns:
A class with all matching information.

void QaRegExp::split( const QString &s )

Splits up the string using the regexp string as the delimiter.

Parameters:
s - The string to split.

int QaRegExp::subCount() const

Returns:
The subexpression count, excluding the master expression.

void QaRegExp::setExpression( const QString &r )

QaRegExp& QaRegExp::operator =( const QaRegExp &r )


The documentation for this class was generated from the following files:
Generated at Mon Aug 16 02:11:02 1999 for QaRegExp by doxygen  written by Dimitri van Heesch, © 1997-1998