|
|
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 Weis |
Please notice that KRegExp does not support unicode.
|
Create a KRegExp object without a default pattern.
|
Create a KRegExp object.
Parameters:
~ |
bool |
Prepare a regular expression for subsequent matches.
Parameters:
bool |
Match a string to the last supplied regexp.
Returns: true
on match, false otherwise.
const char * |
Parameters:
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.
int |
Parameters:
Returns: The start offset of the grouped substring.
int |
Parameters:
Returns: The end offset of the grouped substring. The "end offset" is the first character after the string.
KRegExpPrivate * |
[protected]