20#include <QRegularExpression>
22#include <QDomDocument>
24#ifndef QGSSTRINGUTILS_H
25#define QGSSTRINGUTILS_H
27#define FUZZY_SCORE_WORD_MATCH 5
28#define FUZZY_SCORE_NEW_MATCH 3
29#define FUZZY_SCORE_CONSECUTIVE_MATCH 4
50 const QString &replacement,
51 bool caseSensitive =
false,
52 bool wholeWordOnly =
false );
55 QString
match()
const {
return mMatch; }
71 QString process(
const QString &input )
const;
75 return mMatch == other.mMatch
76 && mReplacement == other.mReplacement
77 && mCaseSensitive == other.mCaseSensitive
78 && mWholeWordOnly == other.mWholeWordOnly;
103 QRegularExpression mRx;
123 : mReplacements( replacements )
130 QList< QgsStringReplacement >
replacements()
const {
return mReplacements; }
140 mReplacements = replacements;
150 QString process(
const QString &input )
const;
158 void writeXml( QDomElement &elem, QDomDocument &doc )
const;
165 void readXml(
const QDomElement &elem );
169 QList< QgsStringReplacement > mReplacements;
200 static QString ampersandEncode(
const QString &
string );
211 static int levenshteinDistance(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
222 static QString longestCommonSubstring(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
233 static int hammingDistance(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
241 static QString soundex(
const QString &
string );
252 static double fuzzyScore(
const QString &candidate,
const QString &search );
261 static QString insertLinks(
const QString &
string,
bool *foundLinks =
nullptr );
269 static bool isUrl(
const QString &
string );
283 static QString wordWrap(
const QString &
string,
int length,
bool useMaxLineLength =
true,
const QString &customDelimiter = QString() );
291 static QString substituteVerticalCharacters( QString
string );
299 static QString htmlToMarkdown(
const QString &html );
307 static QString qRegExpEscape(
const QString &
string );
318 static QString truncateMiddleOfString(
const QString &
string,
int maxLength );
329 static bool containsByWord(
const QString &candidate,
const QString &words, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive );
Capitalization
String capitalization options.
A collection of string replacements (specified using QgsStringReplacement objects).
void setReplacements(const QList< QgsStringReplacement > &replacements)
Sets the list of string replacements in this collection.
QgsStringReplacementCollection(const QList< QgsStringReplacement > &replacements=QList< QgsStringReplacement >())
Constructor for QgsStringReplacementCollection.
QList< QgsStringReplacement > replacements() const
Returns the list of string replacements in this collection.
A representation of a single string replacement.
bool wholeWordOnly() const
Returns true if match only applies to whole words, or false if partial word matches are permitted.
QString replacement() const
Returns the string to replace matches with.
bool caseSensitive() const
Returns true if match is case sensitive.
bool operator==(const QgsStringReplacement &other) const
QString match() const
Returns the string matched by this object.
Utility functions for working with strings.
QMap< QString, QString > QgsStringMap