1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtCore module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
47 #include <QtCore/qstring.h>
54 struct QRegExpPrivate;
57 class Q_CORE_EXPORT QRegExp
67 enum CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch };
70 explicit QRegExp(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive,
71 PatternSyntax syntax = RegExp);
72 QRegExp(const QRegExp &rx);
74 QRegExp &operator=(const QRegExp &rx);
75 #ifdef Q_COMPILER_RVALUE_REFS
76 inline QRegExp &operator=(QRegExp &&other)
77 { qSwap(priv,other.priv); return *this; }
79 inline void swap(QRegExp &other) { qSwap(priv, other.priv); }
81 bool operator==(const QRegExp &rx) const;
82 inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); }
86 QString pattern() const;
87 void setPattern(const QString &pattern);
88 Qt::CaseSensitivity caseSensitivity() const;
89 void setCaseSensitivity(Qt::CaseSensitivity cs);
90 PatternSyntax patternSyntax() const;
91 void setPatternSyntax(PatternSyntax syntax);
93 bool isMinimal() const;
94 void setMinimal(bool minimal);
96 bool exactMatch(const QString &str) const;
98 int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const;
99 int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const;
100 int matchedLength() const;
101 #ifndef QT_NO_REGEXP_CAPTURE
102 int captureCount() const;
103 QStringList capturedTexts() const;
104 QStringList capturedTexts();
105 QString cap(int nth = 0) const;
106 QString cap(int nth = 0);
107 int pos(int nth = 0) const;
108 int pos(int nth = 0);
109 QString errorString() const;
110 QString errorString();
113 static QString escape(const QString &str);
116 QRegExpPrivate *priv;
119 Q_DECLARE_TYPEINFO(QRegExp, Q_MOVABLE_TYPE);
121 #ifndef QT_NO_DATASTREAM
122 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &out, const QRegExp ®Exp);
123 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QRegExp ®Exp);
126 #ifndef QT_NO_DEBUG_STREAM
127 Q_CORE_EXPORT QDebug operator<<(QDebug, const QRegExp &);
134 #endif // QT_NO_REGEXP