8#include <QtCore/qcoreapplication.h>
9#include <QtCore/qhashfunctions.h>
10#include <QtCore/qlist.h>
11#include <QtCore/qmutex.h>
12#include <QtCore/qstringlist.h>
13#include <QtCore/qdebug.h>
14#include <QtCore/qglobal.h>
15#include <QtCore/qatomic.h>
16#include <QtCore/qdatastream.h>
18#if defined(Q_OS_MACOS)
19#include <QtCore/private/qcore_mac_p.h>
22#define PCRE2_CODE_UNIT_WIDTH 16
671 options |= PCRE2_CASELESS;
673 options |= PCRE2_DOTALL;
675 options |= PCRE2_MULTILINE;
677 options |= PCRE2_EXTENDED;
679 options |= PCRE2_UNGREEDY;
681 options |= PCRE2_NO_AUTO_CAPTURE;
683 options |= PCRE2_UCP;
696 options |= PCRE2_ANCHORED;
698 options |= PCRE2_NO_UTF_CHECK;
803 qWarning(
"%s(): called on an invalid QRegularExpression object "
806 qWarning(
"%s(): called on an invalid QRegularExpression object", where);
830 usingCrLfNewlines(
false),
854 patternOptions(
other.patternOptions),
861 usingCrLfNewlines(
false),
893 options |= PCRE2_UTF;
895 PCRE2_SIZE patternErrorOffset;
925 unsigned int patternNewlineSetting;
926 if (pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NEWLINE, &patternNewlineSetting) != 0) {
928 pcre2_config_16(PCRE2_CONFIG_NEWLINE, &patternNewlineSetting);
932 (patternNewlineSetting == PCRE2_NEWLINE_ANY) ||
933 (patternNewlineSetting == PCRE2_NEWLINE_ANYCRLF);
935 unsigned int hasJOptionChanged;
936 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_JCHANGED, &hasJOptionChanged);
938 qWarning(
"QRegularExpressionPrivate::getPatternInfo(): the pattern '%ls'\n is using the (?J) option; duplicate capturing group names are not supported by Qt",
949struct PcreJitStackFree
951 void operator()(pcre2_jit_stack_16 *stack)
954 pcre2_jit_stack_free_16(stack);
957Q_CONSTINIT
static thread_local std::unique_ptr<pcre2_jit_stack_16, PcreJitStackFree> jitStacks;
965 return jitStacks.get();
974 if (!jitEnvironment.
isEmpty()) {
976 int enableJit = jitEnvironment.
toInt(&
ok);
977 return ok ? (enableJit != 0) :
true;
982#elif defined(Q_OS_MACOS)
983 return !qt_mac_runningUnderRosetta();
1007 pcre2_jit_compile_16(
compiledPattern, PCRE2_JIT_COMPLETE | PCRE2_JIT_PARTIAL_SOFT | PCRE2_JIT_PARTIAL_HARD);
1024 PCRE2_SPTR16 *namedCapturingTable;
1025 unsigned int namedCapturingTableEntryCount;
1026 unsigned int namedCapturingTableEntrySize;
1028 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMETABLE, &namedCapturingTable);
1029 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMECOUNT, &namedCapturingTableEntryCount);
1030 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMEENTRYSIZE, &namedCapturingTableEntrySize);
1032 for (
unsigned int i = 0;
i < namedCapturingTableEntryCount; ++
i) {
1033 const auto currentNamedCapturingTableRow =
1034 reinterpret_cast<const char16_t *
>(namedCapturingTable) + namedCapturingTableEntrySize *
i;
1036 if (
name == (currentNamedCapturingTableRow + 1)) {
1037 const int index = *currentNamedCapturingTableRow;
1055 pcre2_match_data_16 *matchData,
1056 pcre2_match_context_16 *matchContext)
1059 startOffset, options, matchData, matchContext);
1061 if (
result == PCRE2_ERROR_JIT_STACKLIMIT && !jitStacks) {
1064 jitStacks.reset(pcre2_jit_stack_create_16(32 * 1024, 512 * 1024, NULL));
1067 startOffset, options, matchData, matchContext);
1107 Q_ASSUME(
priv != previous);
1114 if (offset < 0 || offset > subjectLength)
1124 priv->isValid =
true;
1131 pcreOptions |= PCRE2_PARTIAL_SOFT;
1133 pcreOptions |= PCRE2_PARTIAL_HARD;
1136 pcreOptions |= PCRE2_NO_UTF_CHECK;
1138 bool previousMatchWasEmpty =
false;
1139 if (previous && previous->
hasMatch &&
1141 previousMatchWasEmpty =
true;
1144 pcre2_match_context_16 *matchContext = pcre2_match_context_create_16(
nullptr);
1145 pcre2_jit_stack_assign_16(matchContext, &
qtPcreCallback,
nullptr);
1146 pcre2_match_data_16 *matchData = pcre2_match_data_create_from_pattern_16(
compiledPattern,
nullptr);
1152 const char16_t dummySubject = 0;
1153 const char16_t *
const subjectUtf16 = [&]()
1155 const auto subjectUtf16 =
priv->subject.utf16();
1157 return subjectUtf16;
1159 return &dummySubject;
1164 if (!previousMatchWasEmpty) {
1166 reinterpret_cast<PCRE2_SPTR16
>(subjectUtf16), subjectLength,
1168 matchData, matchContext);
1171 reinterpret_cast<PCRE2_SPTR16
>(subjectUtf16), subjectLength,
1172 offset, pcreOptions | PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED,
1173 matchData, matchContext);
1175 if (
result == PCRE2_ERROR_NOMATCH) {
1179 &&
offset < subjectLength
1180 && subjectUtf16[
offset - 1] == u
'\r'
1181 && subjectUtf16[
offset] == u
'\n') {
1183 }
else if (
offset < subjectLength
1189 reinterpret_cast<PCRE2_SPTR16
>(subjectUtf16), subjectLength,
1191 matchData, matchContext);
1195#ifdef QREGULAREXPRESSION_DEBUG
1198 <<
priv->matchType <<
priv->matchOptions << previousMatchWasEmpty
1207 priv->isValid =
true;
1208 priv->hasMatch =
true;
1213 priv->hasPartialMatch = (
result == PCRE2_ERROR_PARTIAL);
1214 priv->isValid = (
result == PCRE2_ERROR_NOMATCH ||
result == PCRE2_ERROR_PARTIAL);
1216 if (
result == PCRE2_ERROR_PARTIAL) {
1219 priv->capturedCount = 1;
1220 priv->capturedOffsets.resize(2);
1223 priv->capturedCount = 0;
1224 priv->capturedOffsets.clear();
1229 if (
priv->capturedCount) {
1230 PCRE2_SIZE *ovector = pcre2_get_ovector_pointer_16(matchData);
1231 qsizetype *
const capturedOffsets =
priv->capturedOffsets.data();
1237 static_assert(
qsizetype(PCRE2_UNSET) ==
qsizetype(-1),
"Internal error: PCRE2 changed its API");
1239 for (
int i = 0;
i <
priv->capturedCount * 2; ++
i)
1253 if (
result == PCRE2_ERROR_PARTIAL) {
1254 unsigned int maximumLookBehind;
1255 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_MAXLOOKBEHIND, &maximumLookBehind);
1256 capturedOffsets[0] -= maximumLookBehind;
1260 pcre2_match_data_free_16(matchData);
1261 pcre2_match_context_free_16(matchContext);
1268 const QString &subjectStorage,
1271 QRegularExpression::MatchOptions matchOptions)
1272 : regularExpression(re),
1273 subjectStorage(subjectStorage),
1275 matchType(matchType),
1276 matchOptions(matchOptions)
1310 QRegularExpression::MatchOptions matchOptions,
1313 regularExpression(re),
1314 matchType(matchType), matchOptions(matchOptions)
1495 PCRE2_SPTR16 *namedCapturingTable;
1496 unsigned int namedCapturingTableEntryCount;
1497 unsigned int namedCapturingTableEntrySize;
1499 pcre2_pattern_info_16(d->
compiledPattern, PCRE2_INFO_NAMETABLE, &namedCapturingTable);
1500 pcre2_pattern_info_16(d->
compiledPattern, PCRE2_INFO_NAMECOUNT, &namedCapturingTableEntryCount);
1501 pcre2_pattern_info_16(d->
compiledPattern, PCRE2_INFO_NAMEENTRYSIZE, &namedCapturingTableEntrySize);
1506 for (
unsigned int i = 0;
i < namedCapturingTableEntryCount; ++
i) {
1507 const auto currentNamedCapturingTableRow =
1508 reinterpret_cast<const char16_t *
>(namedCapturingTable) + namedCapturingTableEntrySize *
i;
1510 const int index = *currentNamedCapturingTableRow;
1541 int errorStringLength;
1544 errorStringLength = pcre2_get_error_message_16(d->
errorCode,
1547 }
while (errorStringLength < 0);
1550#ifdef QT_NO_TRANSLATION
1556#ifdef QT_NO_TRANSLATION
1557 return u
"no error"_s;
1589 MatchOptions matchOptions)
const
1601#if QT_DEPRECATED_SINCE(6, 8)
1611 MatchType matchType,
1612 MatchOptions matchOptions)
const
1637 MatchOptions matchOptions)
const
1663 MatchOptions matchOptions)
const
1674#if QT_DEPRECATED_SINCE(6, 8)
1684 MatchType matchType,
1685 MatchOptions matchOptions)
const
1712 MatchOptions matchOptions)
const
1745 return (d == re.d) ||
1823 }
else if ((current < u
'a' || current > u
'z') &&
1824 (current < u
'A' || current > u
'Z') &&
1825 (current < u
'0' || current > u
'9') &&
1932 rx.reserve(wclen + wclen / 16);
1936 struct GlobSettings {
1937 char16_t nativePathSeparator;
1942 const GlobSettings
settings = [options]() {
1946 return GlobSettings{ u
'\0', u
"[\\d\\D]*", u
"[\\d\\D]" };
1949 return GlobSettings{ u
'\\', u
"[^/\\\\]*", u
"[^/\\\\]" };
1951 return GlobSettings{ u
'/', u
"[^/]*", u
"[^/]" };
1958 switch (
c.unicode()) {
1999 if (wc[
i] == u
'!') {
2004 if (
i < wclen && wc[
i] == u
']')
2007 while (
i < wclen && wc[
i] != u
']') {
2012 if (wc[
i] == u
'/' || wc[
i] ==
settings.nativePathSeparator)
2047 WildcardConversionOptions options)
2344 if (
name.isEmpty()) {
2345 qWarning(
"QRegularExpressionMatch::captured: empty capturing group name passed");
2366 if (
name.isEmpty()) {
2367 qWarning(
"QRegularExpressionMatch::capturedView: empty capturing group name passed");
2479 if (
name.isEmpty()) {
2480 qWarning(
"QRegularExpressionMatch::capturedStart: empty capturing group name passed");
2502 if (
name.isEmpty()) {
2503 qWarning(
"QRegularExpressionMatch::capturedLength: empty capturing group name passed");
2524 if (
name.isEmpty()) {
2525 qWarning(
"QRegularExpressionMatch::capturedEnd: empty capturing group name passed");
2695 qWarning(
"QRegularExpressionMatchIterator::peekNext() called on an iterator already at end");
2709 qWarning(
"QRegularExpressionMatchIterator::next() called on an iterator already at end");
2765#ifndef QT_NO_DATASTREAM
2792 re.
setPatternOptions(QRegularExpression::PatternOptions::fromInt(patternOptions));
2797#ifndef QT_NO_DEBUG_STREAM
2827 flags =
"NoPatternOption";
2831 flags.append(
"CaseInsensitiveOption|");
2833 flags.append(
"DotMatchesEverythingOption|");
2835 flags.append(
"MultilineOption|");
2837 flags.append(
"ExtendedPatternSyntaxOption|");
2839 flags.append(
"InvertedGreedinessOption|");
2841 flags.append(
"DontCaptureOption|");
2843 flags.append(
"UseUnicodePropertiesOption|");
2847 debug.nospace() <<
"QRegularExpression::PatternOptions(" <<
flags <<
')';
2862 debug.nospace() <<
"QRegularExpressionMatch(";
2864 if (!
match.isValid()) {
2865 debug <<
"Invalid)";
2871 if (
match.hasMatch()) {
2872 debug <<
", has match: ";
2873 for (
int i = 0;
i <=
match.lastCapturedIndex(); ++
i) {
2875 <<
":(" <<
match.capturedStart(
i) <<
", " <<
match.capturedEnd(
i)
2876 <<
", " <<
match.captured(
i) <<
')';
2877 if (
i <
match.lastCapturedIndex())
2880 }
else if (
match.hasPartialMatch()) {
2881 debug <<
", has partial match: ("
2882 <<
match.capturedStart(0) <<
", "
2883 <<
match.capturedEnd(0) <<
", "
2884 <<
match.captured(0) <<
')';
2886 debug <<
", no match";
2935static const char *pcreCompileErrorCodes[] =
2941 QT_TRANSLATE_NOOP(
"QRegularExpression",
"numbers out of order in {} quantifier"),
2943 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing terminating ] for character class"),
2944 QT_TRANSLATE_NOOP(
"QRegularExpression",
"escape sequence is invalid in character class"),
2945 QT_TRANSLATE_NOOP(
"QRegularExpression",
"range out of order in character class"),
2946 QT_TRANSLATE_NOOP(
"QRegularExpression",
"quantifier does not follow a repeatable item"),
2948 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized character after (? or (?-"),
2949 QT_TRANSLATE_NOOP(
"QRegularExpression",
"POSIX named classes are supported only within a class"),
2950 QT_TRANSLATE_NOOP(
"QRegularExpression",
"POSIX collating elements are not supported"),
2952 QT_TRANSLATE_NOOP(
"QRegularExpression",
"reference to non-existent subpattern"),
2954 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognised compile-time option bit(s)"),
2961 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing closing parenthesis for condition"),
2962 QT_TRANSLATE_NOOP(
"QRegularExpression",
"lookbehind assertion is not fixed length"),
2963 QT_TRANSLATE_NOOP(
"QRegularExpression",
"a relative value of zero is not allowed"),
2964 QT_TRANSLATE_NOOP(
"QRegularExpression",
"conditional subpattern contains more than two branches"),
2965 QT_TRANSLATE_NOOP(
"QRegularExpression",
"assertion expected after (?( or (?(?C)"),
2968 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error in pcre2_study(): should not occur"),
2969 QT_TRANSLATE_NOOP(
"QRegularExpression",
"this version of PCRE2 does not have Unicode support"),
2970 QT_TRANSLATE_NOOP(
"QRegularExpression",
"parentheses are too deeply nested (stack check)"),
2971 QT_TRANSLATE_NOOP(
"QRegularExpression",
"character code point value in \\x{} or \\o{} is too large"),
2973 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\C is not allowed in a lookbehind assertion in UTF-" "16" " mode"),
2974 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2 does not support \\F, \\L, \\l, \\N{name}, \\U, or \\u"),
2975 QT_TRANSLATE_NOOP(
"QRegularExpression",
"number after (?C is greater than 255"),
2976 QT_TRANSLATE_NOOP(
"QRegularExpression",
"closing parenthesis for (?C expected"),
2977 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid escape sequence in (*VERB) name"),
2979 QT_TRANSLATE_NOOP(
"QRegularExpression",
"syntax error in subpattern name (missing terminator?)"),
2980 QT_TRANSLATE_NOOP(
"QRegularExpression",
"two named subpatterns have the same name (PCRE2_DUPNAMES not set)"),
2981 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name must start with a non-digit"),
2982 QT_TRANSLATE_NOOP(
"QRegularExpression",
"this version of PCRE2 does not have support for \\P, \\p, or \\X"),
2984 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unknown property name after \\P or \\p"),
2985 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name is too long (maximum " "32" " code units)"),
2986 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many named subpatterns (maximum " "10000" ")"),
2988 QT_TRANSLATE_NOOP(
"QRegularExpression",
"octal value is greater than \\377 in 8-bit non-UTF-8 mode"),
2989 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: overran compiling workspace"),
2990 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: previously-checked referenced subpattern not found"),
2991 QT_TRANSLATE_NOOP(
"QRegularExpression",
"DEFINE subpattern contains more than one branch"),
2993 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown newline setting"),
2994 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number"),
2995 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(?R (recursive pattern call) must be followed by a closing parenthesis"),
3000 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: parsed pattern overflow"),
3001 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-octal character in \\o{} (closing brace missing?)"),
3002 QT_TRANSLATE_NOOP(
"QRegularExpression",
"different names for subpatterns of the same number are not allowed"),
3004 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-hex character in \\x{} (closing brace missing?)"),
3005 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c must be followed by a printable ASCII character"),
3006 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c must be followed by a letter or one of [\\]^_?"),
3007 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\k is not followed by a braced, angle-bracketed, or quoted name"),
3008 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown meta code in check_lookbehinds()"),
3011 QT_TRANSLATE_NOOP(
"QRegularExpression",
"disallowed Unicode code point (>= 0xd800 && <= 0xdfff)"),
3012 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using UTF is disabled by the application"),
3013 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using UCP is disabled by the application"),
3014 QT_TRANSLATE_NOOP(
"QRegularExpression",
"name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)"),
3015 QT_TRANSLATE_NOOP(
"QRegularExpression",
"character code point value in \\u.... sequence is too large"),
3016 QT_TRANSLATE_NOOP(
"QRegularExpression",
"digits missing in \\x{} or \\o{} or \\N{U+}"),
3017 QT_TRANSLATE_NOOP(
"QRegularExpression",
"syntax error or number too big in (?(VERSION condition"),
3018 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown opcode in auto_possessify()"),
3019 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing terminating delimiter for callout with string argument"),
3020 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized string delimiter follows (?C"),
3021 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using \\C is disabled by the application"),
3022 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(?| and/or (?J: or (?x: parentheses are too deeply nested"),
3023 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using \\C is disabled in this PCRE2 library"),
3024 QT_TRANSLATE_NOOP(
"QRegularExpression",
"regular expression is too complicated"),
3026 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern string is longer than the limit set by the application"),
3027 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown code in parsed pattern"),
3028 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: bad code value in parsed_skip()"),
3029 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES is not allowed in UTF-16 mode"),
3030 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid option bits with PCRE2_LITERAL"),
3031 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\N{U+dddd} is supported only in Unicode (UTF) mode"),
3034 QT_TRANSLATE_NOOP(
"QRegularExpression",
"script runs require Unicode support, which this version of PCRE2 does not have"),
3035 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many capturing groups (maximum 65535)"),
3036 QT_TRANSLATE_NOOP(
"QRegularExpression",
"atomic assertion expected after (?( or (?(?C)"),
3045 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 2 top bits not 0x80"),
3046 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 3 top bits not 0x80"),
3047 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 4 top bits not 0x80"),
3048 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 5 top bits not 0x80"),
3049 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 6 top bits not 0x80"),
3050 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 5-byte character is not allowed (RFC 3629)"),
3051 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 6-byte character is not allowed (RFC 3629)"),
3052 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: code points greater than 0x10ffff are not defined"),
3053 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: code points 0xd800-0xdfff are not defined"),
3054 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 2-byte sequence"),
3055 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 3-byte sequence"),
3056 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 4-byte sequence"),
3057 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 5-byte sequence"),
3058 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 6-byte sequence"),
3059 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: isolated byte with 0x80 bit set"),
3060 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: illegal byte (0xfe or 0xff)"),
3061 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: missing low surrogate at end"),
3063 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: isolated low surrogate"),
3064 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-32 error: code points 0xd800-0xdfff are not defined"),
3065 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-32 error: code points greater than 0x10ffff are not defined"),
3067 QT_TRANSLATE_NOOP(
"QRegularExpression",
"patterns do not all use the same character tables"),
3069 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern compiled in wrong mode: 8/16/32-bit error"),
3075 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid data in workspace for DFA restart"),
3077 QT_TRANSLATE_NOOP(
"QRegularExpression",
"backreference condition or recursion test is not supported for DFA matching"),
3078 QT_TRANSLATE_NOOP(
"QRegularExpression",
"function is not supported for DFA matching"),
3079 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern contains an item that is not supported for DFA matching"),
3080 QT_TRANSLATE_NOOP(
"QRegularExpression",
"workspace size exceeded in DFA matching"),
3081 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error - pattern overwritten?"),
3089 QT_TRANSLATE_NOOP(
"QRegularExpression",
"nested recursion at the same subject position"),
3093 QT_TRANSLATE_NOOP(
"QRegularExpression",
"offset limit set without PCRE2_USE_OFFSET_LIMIT"),
3094 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad escape sequence in replacement string"),
3095 QT_TRANSLATE_NOOP(
"QRegularExpression",
"expected closing curly bracket in replacement string"),
3096 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad substitution in replacement string"),
3097 QT_TRANSLATE_NOOP(
"QRegularExpression",
"match with end before start or start moved backwards is not supported"),
3098 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many replacements (more than INT_MAX)"),
3102 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error - duplicate substitution match"),
3103 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2_MATCH_INVALID_UTF is not supported for DFA matching")
int toInt(bool *ok=nullptr, int base=10) const
Returns the byte array converted to an int using base base, which is ten by default.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
constexpr bool isLowSurrogate() const noexcept
Returns true if the QChar is the low part of a UTF16 surrogate (for example if its code point is in r...
constexpr bool isHighSurrogate() const noexcept
Returns true if the QChar is the high part of a UTF16 surrogate (for example if its code point is in ...
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
\inmodule QtCore\reentrant
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
T * data() const noexcept
Returns a pointer to the shared data object.
const T * constData() const noexcept
Returns a const pointer to the shared data object.
const_reference at(qsizetype i) const noexcept
\inmodule QtCore \reentrant
QRegularExpressionMatch next()
Returns the next match result and advances the iterator by one position.
QRegularExpressionMatchIterator & operator=(const QRegularExpressionMatchIterator &iterator)
Assigns the iterator iterator to this object, and returns a reference to the copy.
bool isValid() const
Returns true if the iterator object was obtained as a result from the QRegularExpression::globalMatch...
~QRegularExpressionMatchIterator()
Destroys the QRegularExpressionMatchIterator object.
QRegularExpressionMatchIterator()
QRegularExpression::MatchOptions matchOptions() const
Returns the match options that were used to get this QRegularExpressionMatchIterator object,...
QRegularExpressionMatch peekNext() const
Returns the next match result without moving the iterator.
bool hasNext() const
Returns true if there is at least one match result ahead of the iterator; otherwise it returns false.
QRegularExpression::MatchType matchType() const
Returns the match type that was used to get this QRegularExpressionMatchIterator object,...
QRegularExpression regularExpression() const
Returns the QRegularExpression object whose globalMatch() function returned this object.
\inmodule QtCore \reentrant
QRegularExpression::MatchOptions matchOptions() const
Returns the match options that were used to get this QRegularExpressionMatch object,...
QRegularExpressionMatch()
QStringView capturedView(int nth=0) const
qsizetype capturedEnd(int nth=0) const
Returns the offset inside the subject string immediately after the ending position of the substring c...
QRegularExpression::MatchType matchType() const
Returns the match type that was used to get this QRegularExpressionMatch object, that is,...
~QRegularExpressionMatch()
Destroys the match result.
bool hasPartialMatch() const
Returns true if the regular expression partially matched against the subject string,...
bool hasCaptured(const QString &name) const
bool isValid() const
Returns true if the match object was obtained as a result from the QRegularExpression::match() functi...
bool hasMatch() const
Returns true if the regular expression matched against the subject string, or false otherwise.
QStringList capturedTexts() const
Returns a list of all strings captured by capturing groups, in the order the groups themselves appear...
qsizetype capturedStart(int nth=0) const
Returns the offset inside the subject string corresponding to the starting position of the substring ...
qsizetype capturedLength(int nth=0) const
Returns the length of the substring captured by the nth capturing group.
int lastCapturedIndex() const
Returns the index of the last capturing group that captured something, including the implicit capturi...
QRegularExpressionMatch & operator=(const QRegularExpressionMatch &match)
Assigns the match result match to this object, and returns a reference to the copy.
QString captured(int nth=0) const
Returns the substring captured by the nth capturing group.
QRegularExpression regularExpression() const
Returns the QRegularExpression object whose match() function returned this object.
QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match)
Writes the match object match into the debug object debug for debugging purposes.
\inmodule QtCore \reentrant
~QRegularExpression()
Destroys the QRegularExpression object.
bool isValid() const
Returns true if the regular expression is a valid regular expression (that is, it contains no syntax ...
@ AnchorAtOffsetMatchOption
@ DontCheckSubjectStringMatchOption
PatternOptions patternOptions() const
Returns the pattern options for the regular expression.
friend class QRegularExpressionMatch
void setPatternOptions(PatternOptions options)
Sets the given options as the pattern options of the regular expression.
int captureCount() const
Returns the number of capturing groups inside the pattern string, or -1 if the regular expression is ...
QDataStream & operator<<(QDataStream &out, const QRegularExpression &re)
Writes the regular expression re to stream out.
QRegularExpression & operator=(const QRegularExpression &re) noexcept
Assigns the regular expression re to this object, and returns a reference to the copy.
qsizetype patternErrorOffset() const
Returns the offset, inside the pattern string, at which an error was found when checking the validity...
static QString escape(const QString &str)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QDataStream & operator>>(QDataStream &in, QRegularExpression &re)
Reads a regular expression from stream in into re.
static QRegularExpression fromWildcard(QStringView pattern, Qt::CaseSensitivity cs=Qt::CaseInsensitive, WildcardConversionOptions options=DefaultWildcardConversion)
void setPattern(const QString &pattern)
Sets the pattern string of the regular expression to pattern.
QStringList namedCaptureGroups() const
@ ExtendedPatternSyntaxOption
@ InvertedGreedinessOption
@ UseUnicodePropertiesOption
@ DotMatchesEverythingOption
friend struct QRegularExpressionMatchPrivate
MatchType
The MatchType enum defines the type of the match that should be attempted against the subject string.
@ PartialPreferCompleteMatch
@ PartialPreferFirstMatch
friend class QRegularExpressionMatchIterator
bool operator==(const QRegularExpression &re) const
Returns true if the regular expression is equal to re, or false otherwise.
QRegularExpressionMatch matchView(QStringView subjectView, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
QString pattern() const
Returns the pattern string of the regular expression.
QRegularExpressionMatch match(const QString &subject, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
Attempts to match the regular expression against the given subject string, starting at the position o...
QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions)
Writes the pattern options patternOptions into the debug object debug for debugging purposes.
QRegularExpressionMatchIterator globalMatchView(QStringView subjectView, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
QString errorString() const
Returns a textual description of the error found when checking the validity of the regular expression...
QRegularExpressionMatchIterator globalMatch(const QString &subject, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
Attempts to perform a global match of the regular expression against the given subject string,...
static QString anchoredPattern(const QString &expression)
static QString wildcardToRegularExpression(const QString &str, WildcardConversionOptions options=DefaultWildcardConversion)
@ NonPathWildcardConversion
@ UnanchoredWildcardConversion
QDebug operator<<(QDebug debug, const QRegularExpression &re)
Writes the regular expression re into the debug object debug for debugging purposes.
QRegularExpression()
Constructs a QRegularExpression object with an empty pattern and no pattern options.
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf16(const char16_t *, qsizetype size=-1)
qsizetype size() const
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
QChar * data()
Returns a pointer to the data stored in the QString.
void resize(qsizetype size)
Sets the size of the string to size characters.
Combined button and popup list for selecting options.
#define Q_DECL_COLD_FUNCTION
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLenum GLuint GLintptr offset
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
static pcre2_jit_stack_16 * qtPcreCallback(void *)
static int convertToPcreOptions(QRegularExpression::PatternOptions patternOptions)
Q_DECL_COLD_FUNCTION void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *where)
static bool isJitEnabled()
static int safe_pcre2_match_16(const pcre2_code_16 *code, PCRE2_SPTR16 subject, qsizetype length, qsizetype startOffset, int options, pcre2_match_data_16 *matchData, pcre2_match_context_16 *matchContext)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
#define qUtf16Printable(string)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
#define QT_TRANSLATE_NOOP(scope, x)
QSettings settings("MySoft", "Star Runner")
[0]
QTextStream out(stdout)
[7]
QRegularExpressionMatch next
QRegularExpressionMatchIteratorPrivate(const QRegularExpression &re, QRegularExpression::MatchType matchType, QRegularExpression::MatchOptions matchOptions, const QRegularExpressionMatch &next)
const QRegularExpression regularExpression
const QRegularExpression::MatchOptions matchOptions
const QRegularExpression::MatchType matchType
QList< qsizetype > capturedOffsets
QRegularExpressionMatchPrivate(const QRegularExpression &re, const QString &subjectStorage, QStringView subject, QRegularExpression::MatchType matchType, QRegularExpression::MatchOptions matchOptions)
const QRegularExpression::MatchType matchType
const QRegularExpression::MatchOptions matchOptions
const QString subjectStorage
QRegularExpressionMatch nextMatch() const
const QRegularExpression regularExpression
const QStringView subject
int captureIndexForName(QStringView name) const
void doMatch(QRegularExpressionMatchPrivate *priv, qsizetype offset, CheckSubjectStringOption checkSubjectStringOption=CheckSubjectString, const QRegularExpressionMatchPrivate *previous=nullptr) const
void cleanCompiledPattern()
QRegularExpressionPrivate()
pcre2_code_16 * compiledPattern
~QRegularExpressionPrivate()
QRegularExpression::PatternOptions patternOptions