• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Public Member Functions | List of all members
KRegExp Class Reference

#include <kregexp.h>

Public Member Functions

 KRegExp ()
 
 KRegExp (const char *_pattern, const char *_mode="")
 
bool compile (const char *_pattern, const char *_mode="")
 
bool match (const char *_string)
 
const char * group (int _grp)
 
int groupStart (int _grp)
 
int groupEnd (int _grp)
 

Detailed Description

Deprecated:
Please use TQRegExp instead.

Regular expression (regexp) matching with back-references.

This was implemented because TQRegExp did not support back-references. It now does and is recommended over KRegExp because of the unicode support and the more powerful API.

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;
KRegExp
Definition: kregexp.h:61
endl
kndbgstream & endl(kndbgstream &s)
Does nothing.
Definition: kdebug.h:583

Output:

Torben Weis
Torben
Weis

Please notice that KRegExp does not support unicode.

Author
Torben Weis weis@.nosp@m.kde..nosp@m.org

Definition at line 60 of file kregexp.h.

Constructor & Destructor Documentation

◆ KRegExp() [1/2]

KRegExp::KRegExp ( )

Creates a KRegExp object without a default pattern.

Definition at line 143 of file kregexp.cpp.

◆ KRegExp() [2/2]

KRegExp::KRegExp ( const char *  _pattern,
const char *  _mode = "" 
)

Creates a KRegExp object.

Parameters
_patternThe regular expression to use for matches.
_modeIf this is "i", case-insensitive matches will be performed.

Definition at line 148 of file kregexp.cpp.

◆ ~KRegExp()

KRegExp::~KRegExp ( )

Definition at line 153 of file kregexp.cpp.

Member Function Documentation

◆ compile()

bool KRegExp::compile ( const char *  _pattern,
const char *  _mode = "" 
)

Prepare a regular expression for subsequent matches.

Parameters
_patternThe regular expression to use for matches.
_modeIf this is "i", case-insensitive matches will be performed.
Returns
bool if successful.

Definition at line 158 of file kregexp.cpp.

◆ group()

const char * KRegExp::group ( int  _grp)

Returns a group from the match.

Parameters
_grpMay be in the range [0..9]. If _grp is 0 then the complete matched string is returned.
Returns
a grouped substring. A substring may be empty. In this case 0 is returned. Otherwise you may not delete or modify the returned value. In addition the returned value becomes invalid after the KRegExp instance is deleted or after match() was called again.

Definition at line 168 of file kregexp.cpp.

◆ groupEnd()

int KRegExp::groupEnd ( int  _grp)

The offset of the given group's end in the string.

Parameters
_grpMay be in the range [0..9]. If _grp is 0 then the end offset of the complete matched string is returned.
Returns
The end offset of the grouped substring. The "end offset" is the first character after the string.

Definition at line 178 of file kregexp.cpp.

◆ groupStart()

int KRegExp::groupStart ( int  _grp)

The offset of the given group in the string.

Parameters
_grpMay be in the range [0..9]. If _grp is 0 then the start offset of the complete matched string is returned.
Returns
The start offset of the grouped substring.

Definition at line 173 of file kregexp.cpp.

◆ match()

bool KRegExp::match ( const char *  _string)

Match a string to the last supplied regexp.

Parameters
_stringthe string to match
Returns
true on match, false otherwise.

Definition at line 163 of file kregexp.cpp.


The documentation for this class was generated from the following files:
  • kregexp.h
  • kregexp.cpp

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.