Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Related Functions

QRegExp Class Reference

The QRegExp class provides pattern matching using regular expressions. More...

Collaboration diagram for QRegExp:
Collaboration graph

List of all members.

Public Types

enum  CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch }
enum  PatternSyntax { RegExp, Wildcard, FixedString, RegExp2 }

Public Member Functions

QString cap (int nth=0) const
QString cap (int nth=0)
QStringList capturedTexts () const
QStringList capturedTexts ()
Qt::CaseSensitivity caseSensitivity () const
QString errorString () const
QString errorString ()
bool exactMatch (const QString &str) const
int indexIn (const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
bool isEmpty () const
bool isMinimal () const
bool isValid () const
int lastIndexIn (const QString &str, int offset=-1, CaretMode caretMode=CaretAtZero) const
int matchedLength () const
int numCaptures () const
bool operator!= (const QRegExp &rx) const
QRegExpoperator= (const QRegExp &rx)
bool operator== (const QRegExp &rx) const
QString pattern () const
PatternSyntax patternSyntax () const
int pos (int nth=0) const
int pos (int nth=0)
 QRegExp ()
 QRegExp (const QString &pattern, Qt::CaseSensitivity cs=Qt::CaseSensitive, PatternSyntax syntax=RegExp)
 QRegExp (const QRegExp &rx)
void setCaseSensitivity (Qt::CaseSensitivity cs)
void setMinimal (bool minimal)
void setPattern (const QString &pattern)
void setPatternSyntax (PatternSyntax syntax)
 ~QRegExp ()

Static Public Member Functions

static QString escape (const QString &str)

Private Attributes


Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &out, const QRegExp &regExp)
QDataStreamoperator>> (QDataStream &in, QRegExp &regExp)

Detailed Description

The QRegExp class provides pattern matching using regular expressions.

regular expression

A regular expression, or "regexp", is a pattern for matching substrings in a text. This is useful in many contexts, e.g.,

Validation A regexp can test whether a substring meets some criteria, e.g. is an integer or contains no whitespace. Searching A regexp provides more powerful pattern matching than simple substring matching, e.g., match one of the words {mail}, {letter} or {correspondence}, but none of the words {email}, {mailman}, {mailer}, {letterbox}, etc. Search and Replace A regexp can replace all occurrences of a substring with a different substring, e.g., replace all occurrences of {&} with {&amp;} except where the {&} is already followed by an {amp;}. String Splitting A regexp can be used to identify where a string should be split apart, e.g. splitting tab-delimited strings.

A brief introduction to regexps is presented, a description of Qt's regexp language, some examples, and the function documentation itself. QRegExp is modeled on Perl's regexp language. It fully supports Unicode. QRegExp can also be used in a simpler, {wildcard mode} that is similar to the functionality found in command shells. The syntax rules used by QRegExp can be changed with setPatternSyntax(). In particular, the pattern syntax can be set to QRegExp::FixedString, which means the pattern to be matched is interpreted as a plain string, i.e., special characters (e.g., backslash) are not escaped.

A good text on regexps is {Mastering Regular Expressions} (Third Edition) by Jeffrey E. F. Friedl, ISBN 0-596-52812-4.

Definition at line 61 of file qregexp.h.

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index