StyleMatching.h header
#include <ew/app/StyleMatching.h>
Namespace ew::app
PhraseMatch struct
struct ew::app::PhraseMatch
One whole-word occurrence of a phrase within analyzed text, as returned by findMatches(). Offsets are UTF-16 code-unit indices into the analyzed text.
Members
qsizetype ew::app::PhraseMatch::offset = 0
Code-unit offset of the match within the analyzed text.
qsizetype ew::app::PhraseMatch::length = 0
Length of the match in code units.
QString ew::app::PhraseMatch::matched
The exact text matched, preserving its original casing.
Functions
std::vector< PhraseMatch > ew::app::findMatches(const QRegularExpression &pattern, QStringView text)
Returns every whole-word occurrence in text of any alternative in pattern (as built by wholeWordAlternation()), in order of appearance.
QRegularExpression ew::app::wholeWordAlternation(const QStringList &phrases)
Builds a case-insensitive, Unicode-aware regular expression matching any of phrases as a whole word or phrase. Phrases are regex-escaped and longer ones are tried first, so "kind of" wins over "kind". A phrase is matched only when it is not adjacent to a word character, so it never matches inside a larger word ("cat" in "category") yet a phrase edged with punctuation ("Acme Inc.", "H.P.", "@Ghost") still matches – unlike a plain boundary, which fails at a non-word-next-to-non-word edge. An empty list yields a pattern that never matches. Build the pattern once (rules cache it) and reuse it across calls.