.TH "KRegExp" 3 "28 Jan 2004" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KRegExp \- Regular expression (regexp) matching with back-references.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kregexp.h>\fP
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKRegExp\fP ()"
.br
.RI "\fICreates a KRegExp object without a default pattern. \fP"
.ti -1c
.RI "\fBKRegExp\fP (const  char *_pattern, const  char *_mode='')"
.br
.RI "\fICreates a KRegExp object. \fP"
.ti -1c
.RI "bool \fBcompile\fP (const  char *_pattern, const  char *_mode='')"
.br
.RI "\fIPrepare a regular expression for subsequent matches. \fP"
.ti -1c
.RI "bool \fBmatch\fP (const  char *_string)"
.br
.RI "\fIMatch a string to the last supplied regexp. \fP"
.ti -1c
.RI "const  char * \fBgroup\fP (int _grp)"
.br
.RI "\fIReturns a group from the match. \fP"
.ti -1c
.RI "int \fBgroupStart\fP (int _grp)"
.br
.RI "\fIThe offset of the given group in the string. \fP"
.ti -1c
.RI "int \fBgroupEnd\fP (int _grp)"
.br
.RI "\fIThe offset of the given group's end in the string. \fP"
.in -1c
.SH "Detailed Description"
.PP 
Regular expression (regexp) matching with back-references. 

This was implemented because \fBQRegExp\fP does not support back-references.
.PP
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 \fBgroup\fP method. This is similar to regular expressions in Perl.
.PP
Example: 
.PP
.nf

  KRegExp ex( '([A-Za-z]+) (.+)' );
  ex.match( '42 Torben Weis' );
  \fBkdDebug()\fP << ex.group(0) << endl;
  \fBkdDebug()\fP << ex.group(1) << endl;
  \fBkdDebug()\fP << ex.group(2) << endl;
 
.PP
 Output: 
.PP
.nf

  Torben Weis
  Torben
  Weis
 
.PP
.PP
Please notice that KRegExp does \fInot\fP support unicode.
.PP
\fBAuthor:\fP
.RS 4
Torben Weis <weis@kde.org> 
.RE
.PP
\fBVersion:\fP
.RS 4
\fBId\fP.RS 4
\fBkregexp.h\fP,v 1.11 2002/09/14 16:49:02 tjansen Exp 
.RE
.PP
.RE
.PP

.PP
Definition at line 54 of file kregexp.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KRegExp::KRegExp ()"
.PP
Creates a KRegExp object without a default pattern. Definition at line 143 of file kregexp.cpp.
.SS "KRegExp::KRegExp (const char * _pattern, const char * _mode = '')"
.PP
Creates a KRegExp object. \fBParameters:\fP
.RS 4
\fI_pattern\fP The regular expression to use for matches. 
.br
\fI_mode\fP If this is 'i', case-insensitive matches will be performed. 
.RE
.PP
Definition at line 148 of file kregexp.cpp.
.SH "Member Function Documentation"
.PP 
.SS "bool KRegExp::compile (const char * _pattern, const char * _mode = '')"
.PP
Prepare a regular expression for subsequent matches. \fBParameters:\fP
.RS 4
\fI_pattern\fP The regular expression to use for matches. 
.br
\fI_mode\fP If this is 'i', case-insensitive matches will be performed. 
.RE
.PP
\fBReturns:\fP
.RS 4
bool if successful. 
.RE
.PP
Definition at line 158 of file kregexp.cpp.
.PP
References KRegExpPrivate::compile().
.SS "bool KRegExp::match (const char * _string)"
.PP
Match a string to the last supplied regexp. \fBParameters:\fP
.RS 4
\fI_string\fP the string to match 
.RE
.PP
\fBReturns:\fP
.RS 4
\fCtrue\fP on match, false otherwise. 
.RE
.PP
Definition at line 163 of file kregexp.cpp.
.PP
References KRegExpPrivate::match().
.SS "const  char * KRegExp::group (int _grp)"
.PP
Returns a group from the match. \fBParameters:\fP
.RS 4
\fI_grp\fP May be in the range [0..9]. If \fC_grp\fP is 0 then the complete matched string is returned. 
.RE
.PP
\fBReturns:\fP
.RS 4
a grouped substring. A substring may be empty. In this case 0 is returned. Otherwise you may \fInot\fP delete or modify the returned value. In addition the returned value becomes invalid after the KRegExp instance is deleted or after \fBmatch\fP() was called again. 
.RE
.PP
Definition at line 168 of file kregexp.cpp.
.PP
References KRegExpPrivate::group().
.SS "int KRegExp::groupStart (int _grp)"
.PP
The offset of the given group in the string. \fBParameters:\fP
.RS 4
\fI_grp\fP May be in the range [0..9]. If \fC_grp\fP is 0 then the start offset of the complete matched string is returned. 
.RE
.PP
\fBReturns:\fP
.RS 4
The start offset of the grouped substring. 
.RE
.PP
Definition at line 173 of file kregexp.cpp.
.PP
References KRegExpPrivate::groupStart().
.SS "int KRegExp::groupEnd (int _grp)"
.PP
The offset of the given group's end in the string. \fBParameters:\fP
.RS 4
\fI_grp\fP May be in the range [0..9]. If \fC_grp\fP is 0 then the end offset of the complete matched string is returned. 
.RE
.PP
\fBReturns:\fP
.RS 4
The end offset of the grouped substring. The 'end offset' is the first character after the string. 
.RE
.PP
Definition at line 178 of file kregexp.cpp.
.PP
References KRegExpPrivate::groupEnd().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
