KRegExp Class Reference
Regular expression (regexp) matching with back-references. More...
#include <kregexp.h>
Collaboration diagram for KRegExp:

Public Member Functions | |
KRegExp () | |
Creates a KRegExp object without a default pattern. | |
KRegExp (const char *_pattern, const char *_mode="") | |
Creates a KRegExp object. | |
bool | compile (const char *_pattern, const char *_mode="") |
Prepare a regular expression for subsequent matches. | |
bool | match (const char *_string) |
Match a string to the last supplied regexp. | |
const char * | group (int _grp) |
Returns a group from the match. | |
int | groupStart (int _grp) |
The offset of the given group in the string. | |
int | groupEnd (int _grp) |
The offset of the given group's end in the string. |
Detailed Description
Regular expression (regexp) matching with back-references.This was implemented because QRegExp does not support back-references.
Back-references are parts of a regexp grouped with parentheses. If a string matches the regexp, you can access the text that matched each group with the group method. This is similar to regular expressions in Perl.
Example:
KRegExp ex( "([A-Za-z]+) (.+)" ); ex.match( "42 Torben Weis" ); kdDebug() << ex.group(0) << endl; kdDebug() << ex.group(1) << endl; kdDebug() << ex.group(2) << endl;Output:Torben Weis Torben WeisPlease notice that KRegExp does not support unicode.
- Author:
- Torben Weis <weis@kde.org>
- Version:
- Id
- kregexp.h,v 1.11 2002/09/14 16:49:02 tjansen Exp
Definition at line 54 of file kregexp.h.
Constructor & Destructor Documentation
|
Creates a KRegExp object without a default pattern.
Definition at line 143 of file kregexp.cpp. |
|
Creates a KRegExp object.
Definition at line 148 of file kregexp.cpp. |
Member Function Documentation
|
Prepare a regular expression for subsequent matches.
Definition at line 158 of file kregexp.cpp. References KRegExpPrivate::compile(). |
|
Match a string to the last supplied regexp.
Definition at line 163 of file kregexp.cpp. References KRegExpPrivate::match(). |
|
Returns a group from the match.
Definition at line 168 of file kregexp.cpp. References KRegExpPrivate::group(). |
|
The offset of the given group in the string.
Definition at line 173 of file kregexp.cpp. References KRegExpPrivate::groupStart(). |
|
The offset of the given group's end in the string.
Definition at line 178 of file kregexp.cpp. References KRegExpPrivate::groupEnd(). |
The documentation for this class was generated from the following files: