QRegExp Class Reference


The QRegExp class provides pattern matching using regular expressions and wildcards. (details) (complete member list)

#include <qregexp.h>

Public Members

Protected Members


Detailed Description

The QRegExp class provides pattern matching using regular expressions and wildcards.

QRegExp knows these regexp primitives:

In wildcard mode, it only knows three primitives:


Member Function Documentation

QRegExp::QRegExp ()

Constructs an empty regular expression.

QRegExp::QRegExp (const char *pattern, bool caseSensitive=TRUE, bool wildcard=FALSE)

Constructs a regular expression.

Arguments:

QRegExp::QRegExp (const QRegExp &r)

Constructs a regular expression which is a copy of r.

See also: operator=(const QRegExp&).

QRegExp::~QRegExp ()

Destroys the regular expression and cleans up its internal data.

bool QRegExp::caseSensitive () const

Returns TRUE if case-sensitivity is enabled, otherwise FALSE.

See also: setCaseSensitive().

bool QRegExp::isEmpty () const

Returns TRUE if the regexp is empty.

bool QRegExp::isValid () const

Returns TRUE if the regexp is valid, or FALSE if it is invalid.

The pattern "[a-z" is an example of an invalid pattern, since it lacks a closing bracket.

int QRegExp::match (const char *str, int index=0, int *len=0) const

Attempts to match in str, starting from position index. Returns the position of the match, or -1 if there was no match.

If len is not a null pointer, the length of the match is stored in *len.

QRegExp r("[0-9]*\.[0-9]+");            // matches floating point
int     len;
r.match("pi = 3.1416", 0, &len);        // returns 5, len == 6

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

Copies the regexp r and returns a reference to this regexp. The case-sensitivity and wildcard options are copied, as well.

QRegExp & QRegExp::operator= (const char *pattern)

Sets the pattern string to pattern and returns a reference to this regexp. The case-sensitivity or wildcard options do not change.

bool QRegExp::operator== (const QRegExp &r) const

Returns TRUE if this regexp is equal to r. Two regexp objects are equal if they have the equal pattern strings, case-sensitivity options and wildcard options.

const char * QRegExp::pattern () const

Returns the pattern string of the regexp.

void QRegExp::setCaseSensitive (bool enable)

Enables or disables case-sensitive matching.

In case-sensitive mode, "a.e" matches "axe" but not "Axe".

See also: caseSensitive().

void QRegExp::setWildcard (bool wildcard)

Sets the wildcard option for the regular expression.

Setting wildcard to TRUE makes it convenient to match filenames instead of plain text.

For example, "qr*.cpp" matches the string "qregexp.cpp" in wildcard mode, but not "qicpp" (which will be matched in normal mode).

See also: wildcard().

bool QRegExp::wildcard () const

Returns TRUE if wildcard mode is on, otherwise FALSE.

See also: setWildcard().


This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 04:27, 1995/05/20 by the webmaster at Troll Tech