The QRegExp class provides pattern matching using regular expressions or wildcards. More...
#include <qregexp.h>
QRegExp knows these regexp primitives:
In wildcard mode, it only knows four primitives:
QRegExp supports Unicode both in the pattern strings and in the strings to be matched.
When writing regular expressions in C++ code, remember that C++ processes \ characters. So in order to match e.g. a "." character, you must write "\\." in C++ source, not "\.".
A character set matches a defined set of characters. For example, [BSD] matches any of 'B', 'D' and 'S'. Within a character set, the special characters '.', '*', '?', '^', '$', '+' and '[' lose their special meanings. The following special characters apply:
\note In Qt 3.0, the language of regular expressions will contain five more special characters, namely '(', ')', '{', '|' and '}'. To ease porting, it's a good idea to escape these characters with a backslash in all the regular expressions you'll write from now on.
Bugs and limitations:
Examples: qmag/qmag.cpp
Constructs an empty regular expression.
Constructs a regular expression.
Arguments:
See also setWildcard().
Constructs a regular expression which is a copy of r.
See also operator=(const and QRegExp&).
Destructs the regular expression and cleans up its internal data.
Returns TRUE if case sensitivity is enabled, otherwise FALSE. The default is TRUE.
See also setCaseSensitive().
Attempts to match in str, starting from position index. Returns the position of the match, or -1 if there was no match.
See also match().
Returns TRUE if the regexp is empty.
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.
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.
If indexIsStart is TRUE (the default), the position index in the string will match the start-of-input primitive (^) in the regexp, if present. Otherwise, position 0 in str will match.
Example:
QRegExp r("[0-9]*\\.[0-9]+"); // matches floating point int len; r.match("pi = 3.1416", 0, &len); // returns 5, len == 6
\note In Qt 3.0, this function will be replaced by find().
Examples: qmag/qmag.cpp
Returns TRUE if this regexp is not equal to r.
See also operator==().
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Consider using setPattern() instead of this method.
Sets the pattern string to pattern and returns a reference to this regexp. The case sensitivity or wildcard options do not change.
Copies the regexp r and returns a reference to this regexp. The case sensitivity and wildcard options are copied, as well.
Returns TRUE if this regexp is equal to r.
Two regexp objects are equal if they have equal pattern strings, case sensitivity options and wildcard options.
Returns the pattern string of the regexp.
Enables or disables case sensitive matching.
In case sensitive mode, "a.e" matches "axe" but not "Axe".
See also: caseSensitive().
Sets the pattern string to pattern and returns a reference to this regexp. The case sensitivity or wildcard options do not change.
Sets the wildcard option for the regular expression. The default is FALSE.
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 would be matched in normal mode).
See also wildcard().
Returns TRUE if wildcard mode is on, otherwise FALSE.
See also setWildcard().
[protected]
For internal use only.
[protected]
For internal use only.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright © 2000 Trolltech | Trademarks | Qt version 2.2.1
|