Search for usage in LXR

#include <kateregexpsearch.h>

Public Member Functions

 KateRegExpSearch (const KTextEditor::Document *document)
QVector< KTextEditor::Rangesearch (const QString &pattern, KTextEditor::Range inputRange, bool backwards=false, QRegularExpression::PatternOptions options=QRegularExpression::NoPatternOption)

Static Public Member Functions

static QString buildReplacement (const QString &text, const QStringList &capturedTexts, int replacementCounter)
static QString escapePlaintext (const QString &text)

Detailed Description

Object to help to search for regexp.

This should be NO QObject, it is created to often! I measured that, if you create it 20k times to replace for example " " in a document, that takes seconds on a modern machine!

Definition at line 28 of file kateregexpsearch.h.

Member Function Documentation

◆ buildReplacement()

QString KateRegExpSearch::buildReplacement ( const QString text,
const QStringList capturedTexts,
int  replacementCounter 

Returns a modified version of text where.

  • escape sequences are resolved, e.g. "\\n" to "\n",
  • references are resolved, e.g. "\\1" to 1st entry in capturedTexts, and
  • counter sequences are resolved, e.g. "\\#...#" to replacementCounter.
texttext containing escape sequences, references, and counter sequences
capturedTextslist of substitutes for references
replacementCountervalue for replacement counter
resolved text

Definition at line 493 of file kateregexpsearch.cpp.

◆ escapePlaintext()

QString KateRegExpSearch::escapePlaintext ( const QString text)

Returns a modified version of text where escape sequences are resolved, e.g.

"\\n" to "\n".

texttext containing escape sequences
text with resolved escape sequences

Definition at line 488 of file kateregexpsearch.cpp.

◆ search()

QVector< KTextEditor::Range > KateRegExpSearch::search ( const QString pattern,
KTextEditor::Range  inputRange,
bool  backwards = false,
QRegularExpression::PatternOptions  options = QRegularExpression::NoPatternOption 

Search for the regular expression pattern inside the range inputRange.

If backwards is true, the search direction will be reversed. options is a set of QRegularExpression::PatternOptions OR flags that control certain aspects of the search, e.g. case sensitivity and if the dot "." metacharacter matches any character including a newline.

Note: Unicode support is always enabled (QRegularExpression::UseUnicodePropertiesOption). If the pattern is multi-line the QRegularExpression::MultilineOption is enabled.

patterntext to search for
inputRangeRange to search in
backwardsif true, the search will be backwards
optionsQRegularExpression pattern options, we will internally add QRegularExpression::UseUnicodePropertiesOption
Vector of ranges, one for each capture group. The first range (index zero) spans the whole match. If no matches are found, the vector will contain one element, an invalid range (see Range::isValid()).
See also
KTextEditor::Range, QRegularExpression

Definition at line 167 of file kateregexpsearch.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 03:49:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.