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

QRegExp Class Reference

List of all members.

Detailed Description

The QRegExp class provides pattern matching using regular expressions.

regular expression

Regular expressions, or "regexps", provide a way to find patterns within text. This is useful in many contexts, for example:

Validation A regexp can be used to check whether a piece of text meets some criteria, e.g. is an integer or contains no whitespace. Searching Regexps provide a much more powerful means of searching text than simple string matching does. For example we can create a regexp which says "find one of the words 'mail', 'letter' or 'correspondence' but not any of the words 'email', 'mailman' 'mailer', 'letterbox', etc." Search and Replace A regexp can be used to replace a pattern with a piece of text, for example replace all occurrences of '&' with '&' except where the '&' is already followed by 'amp;'. String Splitting A regexp can be used to identify where a string should be split into its component fields, e.g. splitting tab-delimited strings.

We present a very brief introduction to regexps, a description of Qt's regexp language, some code examples, and finally the function documentation itself. QRegExp is modeled on Perl's regexp language, and also fully supports Unicode. QRegExp can also be used in the weaker wildcard mode that works in a similar way to command shells. It can even be feed with fixed strings (see setPatternSyntax()). 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.

Public Types

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

Public Member Functions

QString cap (int nth=0)
QStringList capturedTexts ()
Qt::CaseSensitivity caseSensitivity () 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)
 QRegExp (const QRegExp &rx)
 QRegExp (const QString &pattern, Qt::CaseSensitivity cs=Qt::CaseSensitive, PatternSyntax syntax=RegExp)
 QRegExp ()
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

QRegExpPrivate * priv

Related Functions

(Note that these are not member functions.)

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

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

Generated by  Doxygen 1.6.0   Back to index