QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
|
Utility functions for working with strings. More...
#include <qgsstringutils.h>
Static Public Member Functions | |
static QString | ampersandEncode (const QString &string) |
Makes a raw string safe for inclusion as a HTML/XML string literal. More... | |
static QString | capitalize (const QString &string, Qgis::Capitalization capitalization) |
Converts a string by applying capitalization rules to the string. More... | |
static double | fuzzyScore (const QString &candidate, const QString &search) |
Tests a candidate string to see how likely it is a match for a specified search string. More... | |
static int | hammingDistance (const QString &string1, const QString &string2, bool caseSensitive=false) |
Returns the Hamming distance between two strings. More... | |
static QString | htmlToMarkdown (const QString &html) |
Convert simple HTML to markdown. More... | |
static QString | insertLinks (const QString &string, bool *foundLinks=nullptr) |
Returns a string with any URL (e.g., http(s)/ftp) and mailto: text converted to valid HTML <a ...> links. More... | |
static bool | isUrl (const QString &string) |
Returns whether the string is a URL (http,https,ftp,file) More... | |
static int | levenshteinDistance (const QString &string1, const QString &string2, bool caseSensitive=false) |
Returns the Levenshtein edit distance between two strings. More... | |
static QString | longestCommonSubstring (const QString &string1, const QString &string2, bool caseSensitive=false) |
Returns the longest common substring between two strings. More... | |
static QString | qRegExpEscape (const QString &string) |
Returns an escaped string matching the behavior of QRegExp::escape. More... | |
static QString | soundex (const QString &string) |
Returns the Soundex representation of a string. More... | |
static QString | substituteVerticalCharacters (QString string) |
Returns a string with characters having vertical representation form substituted. More... | |
static QString | truncateMiddleOfString (const QString &string, int maxLength) |
Truncates a string to the specified maximum character length. More... | |
static QString | wordWrap (const QString &string, int length, bool useMaxLineLength=true, const QString &customDelimiter=QString()) |
Automatically wraps a string by inserting new line characters at appropriate locations in the string. More... | |
Utility functions for working with strings.
Definition at line 183 of file qgsstringutils.h.
|
static |
Makes a raw string safe for inclusion as a HTML/XML string literal.
This includes replacing '<' with '<', '>' with '>', '&' with '&', and any extended unicode characters with the XML style é encoded versions of these characters.
Definition at line 118 of file qgsstringutils.cpp.
|
static |
Converts a string by applying capitalization rules to the string.
string | input string |
capitalization | capitalization type to apply |
Definition at line 24 of file qgsstringutils.cpp.
|
static |
Tests a candidate string to see how likely it is a match for a specified search string.
Values are normalized between 0 and 1.
candidate | candidate string |
search | search term string |
Definition at line 418 of file qgsstringutils.cpp.
|
static |
Returns the Hamming distance between two strings.
This equates to the number of characters at corresponding positions within the input strings where the characters are different. The input strings must be the same length.
string1 | first string |
string2 | second string |
caseSensitive | set to true for case sensitive comparison |
Definition at line 283 of file qgsstringutils.cpp.
|
static |
Convert simple HTML to markdown.
Only br, b and link are supported.
html | HTML to convert to markdown |
Definition at line 574 of file qgsstringutils.cpp.
|
static |
Returns a string with any URL (e.g., http(s)/ftp) and mailto: text converted to valid HTML <a ...> links.
string | string to insert links into |
foundLinks | if specified, will be set to true if any links were inserted into the string |
Definition at line 522 of file qgsstringutils.cpp.
|
static |
Returns whether the string is a URL (http,https,ftp,file)
string | the string to check |
Definition at line 568 of file qgsstringutils.cpp.
|
static |
Returns the Levenshtein edit distance between two strings.
This equates to the minimum number of character edits (insertions, deletions or substitutions) required to change one string to another.
string1 | first string |
string2 | second string |
caseSensitive | set to true for case sensitive comparison |
Definition at line 138 of file qgsstringutils.cpp.
|
static |
Returns the longest common substring between two strings.
This substring is the longest string that is a substring of the two input strings. For example, the longest common substring of "ABABC" and "BABCA" is "ABC".
string1 | first string |
string2 | second string |
caseSensitive | set to true for case sensitive comparison |
Definition at line 220 of file qgsstringutils.cpp.
|
static |
Returns an escaped string matching the behavior of QRegExp::escape.
string | String to escape |
Definition at line 710 of file qgsstringutils.cpp.
|
static |
Returns the Soundex representation of a string.
Soundex is a phonetic matching algorithm, so strings with similar sounds should be represented by the same Soundex code.
string | input string |
Definition at line 322 of file qgsstringutils.cpp.
|
static |
Returns a string with characters having vertical representation form substituted.
string | input string |
Definition at line 688 of file qgsstringutils.cpp.
|
static |
Truncates a string to the specified maximum character length.
If the string exceeds the maximum character length, then the string will be truncated by removing characters from the middle of the string and replacing them with a horizontal ellipsis character.
Definition at line 743 of file qgsstringutils.cpp.
|
static |
Automatically wraps a string by inserting new line characters at appropriate locations in the string.
The length argument specifies either the minimum or maximum length of lines desired, depending on whether useMaxLineLength is true
. If useMaxLineLength is TRUE, then the string will be wrapped so that each line ideally will not exceed length of characters. If useMaxLineLength is false
, then the string will be wrapped so that each line will ideally exceed length of characters.
A custom delimiter can be specified to use instead of space characters.
Definition at line 602 of file qgsstringutils.cpp.