9#include <QtCore/qcoreapplication.h>
10#include <QtCore/qhashfunctions.h>
11#include <QtCore/qlist.h>
12#include <QtCore/qmutex.h>
13#include <QtCore/qstringlist.h>
14#include <QtCore/qdebug.h>
15#include <QtCore/qglobal.h>
16#include <QtCore/qatomic.h>
17#include <QtCore/qdatastream.h>
19#if defined(Q_OS_MACOS)
20#include <QtCore/private/qcore_mac_p.h>
23#define PCRE2_CODE_UNIT_WIDTH 16
29using namespace Qt::StringLiterals;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
680
681
686 if (patternOptions & QRegularExpression::CaseInsensitiveOption)
687 options |= PCRE2_CASELESS;
688 if (patternOptions & QRegularExpression::DotMatchesEverythingOption)
689 options |= PCRE2_DOTALL;
690 if (patternOptions & QRegularExpression::MultilineOption)
691 options |= PCRE2_MULTILINE;
692 if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption)
693 options |= PCRE2_EXTENDED;
694 if (patternOptions & QRegularExpression::InvertedGreedinessOption)
695 options |= PCRE2_UNGREEDY;
696 if (patternOptions & QRegularExpression::DontCaptureOption)
697 options |= PCRE2_NO_AUTO_CAPTURE;
698 if (patternOptions & QRegularExpression::UseUnicodePropertiesOption)
699 options |= PCRE2_UCP;
705
706
711 if (matchOptions & QRegularExpression::AnchorAtOffsetMatchOption)
712 options |= PCRE2_ANCHORED;
713 if (matchOptions & QRegularExpression::DontCheckSubjectStringMatchOption)
714 options |= PCRE2_NO_UTF_CHECK;
765 const QString &subjectStorage,
767 QRegularExpression::MatchType matchType,
768 QRegularExpression::MatchOptions matchOptions);
797 QRegularExpression::MatchType matchType,
798 QRegularExpression::MatchOptions matchOptions,
799 const QRegularExpressionMatch &next);
809
810
811
812
813
814
818 if (pattern.isValidUtf16()) {
819 qWarning(
"%s::%s(): called on an invalid QRegularExpression object "
820 "(pattern is '%ls')", cls, method, qUtf16Printable(pattern));
822 qWarning(
"%s::%s(): called on an invalid QRegularExpression object",
828
829
830QRegularExpression::QRegularExpression(QRegularExpressionPrivate &dd)
836
837
853
854
861
862
863
864
865
866
867
868
884
885
897
898
901 const QMutexLocker lock(&mutex);
909 int options = convertToPcreOptions(patternOptions);
910 options |= PCRE2_UTF;
912 PCRE2_SIZE patternErrorOffset;
913 compiledPattern = pcre2_compile_16(
reinterpret_cast<PCRE2_SPTR16>(pattern.constData()),
921 errorOffset = qsizetype(patternErrorOffset);
933
934
942 unsigned int patternNewlineSetting;
943 if (pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NEWLINE, &patternNewlineSetting) != 0) {
945 pcre2_config_16(PCRE2_CONFIG_NEWLINE, &patternNewlineSetting);
949 (patternNewlineSetting == PCRE2_NEWLINE_ANY) ||
950 (patternNewlineSetting == PCRE2_NEWLINE_ANYCRLF);
952 unsigned int hasJOptionChanged;
953 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_JCHANGED, &hasJOptionChanged);
954 if (Q_UNLIKELY(hasJOptionChanged)) {
955 qWarning(
"QRegularExpressionPrivate::getPatternInfo(): the pattern '%ls'\n is using the (?J) option; duplicate capturing group names are not supported by Qt",
956 qUtf16Printable(pattern));
962
963
964
966struct PcreJitStackFree
968 void operator()(pcre2_jit_stack_16 *stack)
const
971 pcre2_jit_stack_free_16(stack);
974Q_CONSTINIT
static thread_local std::unique_ptr<pcre2_jit_stack_16, PcreJitStackFree> jitStacks;
978
979
982 return jitStacks.get();
986
987
990 QByteArray jitEnvironment = qgetenv(
"QT_ENABLE_REGEXP_JIT");
991 if (!jitEnvironment.isEmpty()) {
993 int enableJit = jitEnvironment.toInt(&ok);
994 return ok ? (enableJit != 0) :
true;
999#elif defined(Q_OS_MACOS) && !defined(QT_BOOTSTRAPPED)
1000 return !qt_mac_runningUnderRosetta();
1007
1008
1009
1010
1011
1012
1013
1014
1024 pcre2_jit_compile_16(
compiledPattern, PCRE2_JIT_COMPLETE | PCRE2_JIT_PARTIAL_SOFT | PCRE2_JIT_PARTIAL_HARD);
1028
1029
1030
1031
1032
1035 Q_ASSERT(!name.isEmpty());
1041 PCRE2_SPTR16 *namedCapturingTable;
1042 unsigned int namedCapturingTableEntryCount;
1043 unsigned int namedCapturingTableEntrySize;
1045 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMETABLE, &namedCapturingTable);
1046 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMECOUNT, &namedCapturingTableEntryCount);
1047 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMEENTRYSIZE, &namedCapturingTableEntrySize);
1049 for (
unsigned int i = 0; i < namedCapturingTableEntryCount; ++i) {
1050 const auto currentNamedCapturingTableRow =
1051 reinterpret_cast<
const char16_t *>(namedCapturingTable) + namedCapturingTableEntrySize * i;
1053 if (name == (currentNamedCapturingTableRow + 1)) {
1054 const int index = *currentNamedCapturingTableRow;
1063
1064
1065
1066
1067
1068
1070 PCRE2_SPTR16 subject, qsizetype length,
1071 qsizetype startOffset,
int options,
1072 pcre2_match_data_16 *matchData,
1073 pcre2_match_context_16 *matchContext)
1075 int result = pcre2_match_16(code, subject, length,
1076 startOffset, options, matchData, matchContext);
1078 if (result == PCRE2_ERROR_JIT_STACKLIMIT && !jitStacks) {
1081 jitStacks.reset(pcre2_jit_stack_create_16(32 * 1024, 512 * 1024, NULL));
1083 result = pcre2_match_16(code, subject, length,
1084 startOffset, options, matchData, matchContext);
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1124 Q_ASSERT(priv != previous);
1126 const qsizetype subjectLength = priv->subject.size();
1129 offset += subjectLength;
1131 if (offset < 0 || offset > subjectLength)
1135 qtWarnAboutInvalidRegularExpression(pattern,
"QRegularExpressionPrivate",
"doMatch");
1140 if (priv->matchType == QRegularExpression::NoMatch) {
1145 int pcreOptions = convertToPcreOptions(priv->matchOptions);
1147 if (priv->matchType == QRegularExpression::PartialPreferCompleteMatch)
1148 pcreOptions |= PCRE2_PARTIAL_SOFT;
1149 else if (priv->matchType == QRegularExpression::PartialPreferFirstMatch)
1150 pcreOptions |= PCRE2_PARTIAL_HARD;
1153 pcreOptions |= PCRE2_NO_UTF_CHECK;
1155 bool previousMatchWasEmpty =
false;
1157 (previous->capturedOffsets.at(0) == previous->capturedOffsets.at(1))) {
1158 previousMatchWasEmpty =
true;
1161 pcre2_match_context_16 *matchContext = pcre2_match_context_create_16(
nullptr);
1162 pcre2_jit_stack_assign_16(matchContext, &
qtPcreCallback,
nullptr);
1163 pcre2_match_data_16 *matchData = pcre2_match_data_create_from_pattern_16(
compiledPattern,
nullptr);
1169 const char16_t dummySubject = 0;
1170 const char16_t *
const subjectUtf16 = [&]()
1172 const auto subjectUtf16 = priv->subject.utf16();
1174 return subjectUtf16;
1175 Q_ASSERT(subjectLength == 0);
1176 return &dummySubject;
1181 if (!previousMatchWasEmpty) {
1182 result = safe_pcre2_match_16(compiledPattern,
1183 reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
1184 offset, pcreOptions,
1185 matchData, matchContext);
1187 result = safe_pcre2_match_16(compiledPattern,
1188 reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
1189 offset, pcreOptions | PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED,
1190 matchData, matchContext);
1192 if (result == PCRE2_ERROR_NOMATCH) {
1196 && offset < subjectLength
1197 && subjectUtf16[offset - 1] == u'\r'
1198 && subjectUtf16[offset] == u'\n') {
1200 }
else if (offset < subjectLength
1201 && QChar::isLowSurrogate(subjectUtf16[offset])) {
1205 result = safe_pcre2_match_16(compiledPattern,
1206 reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
1207 offset, pcreOptions,
1208 matchData, matchContext);
1212#ifdef QREGULAREXPRESSION_DEBUG
1213 qDebug() <<
"Matching" << pattern <<
"against" << subject
1214 <<
"offset" << offset
1215 << priv->matchType << priv->matchOptions << previousMatchWasEmpty
1216 <<
"result" << result;
1220 Q_ASSERT(result != 0);
1227 priv->capturedOffsets.resize(result * 2);
1231 priv
->isValid = (result == PCRE2_ERROR_NOMATCH || result == PCRE2_ERROR_PARTIAL);
1233 if (result == PCRE2_ERROR_PARTIAL) {
1237 priv->capturedOffsets.resize(2);
1241 priv->capturedOffsets.clear();
1247 PCRE2_SIZE *ovector = pcre2_get_ovector_pointer_16(matchData);
1248 qsizetype *
const capturedOffsets = priv->capturedOffsets.data();
1254 static_assert(qsizetype(PCRE2_UNSET) == qsizetype(-1),
"Internal error: PCRE2 changed its API");
1257 capturedOffsets[i] = qsizetype(ovector[i]);
1270 if (result == PCRE2_ERROR_PARTIAL) {
1271 unsigned int maximumLookBehind;
1272 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_MAXLOOKBEHIND, &maximumLookBehind);
1273 capturedOffsets[0] -= maximumLookBehind;
1277 pcre2_match_data_free_16(matchData);
1278 pcre2_match_context_free_16(matchContext);
1282
1283
1285 const QString &subjectStorage,
1286 QStringView subject,
1287 QRegularExpression::MatchType matchType,
1288 QRegularExpression::MatchOptions matchOptions)
1298
1299
1305 auto nextPrivate =
new QRegularExpressionMatchPrivate(regularExpression,
1315 regularExpression.d->doMatch(nextPrivate,
1316 capturedOffsets.at(1),
1317 QRegularExpressionPrivate::DontCheckSubjectString,
1319 return QRegularExpressionMatch(*nextPrivate);
1323
1324
1326 QRegularExpression::MatchType matchType,
1327 QRegularExpression::MatchOptions matchOptions,
1328 const QRegularExpressionMatch &next)
1336
1337
1340 return next.isValid() && (next.hasMatch() || next.hasPartialMatch());
1346
1347
1348
1349
1350
1351QRegularExpression::QRegularExpression()
1352 : d(
new QRegularExpressionPrivate)
1357
1358
1359
1360
1361
1362
1363
1364
1365QRegularExpression::QRegularExpression(
const QString &pattern, PatternOptions options)
1366 : d(
new QRegularExpressionPrivate)
1368 d->pattern = pattern;
1369 d->patternOptions = options;
1373
1374
1375
1376
1377QRegularExpression::QRegularExpression(
const QRegularExpression &re)
noexcept =
default;
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1394
1395
1396QRegularExpression::~QRegularExpression()
1400QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QRegularExpressionPrivate)
1403
1404
1405
1406QRegularExpression &QRegularExpression::operator=(
const QRegularExpression &re)
noexcept =
default;
1409
1410
1411
1414
1415
1416
1417
1418QString QRegularExpression::pattern()
const
1424
1425
1426
1427
1428
1429
1430
1431
1432void QRegularExpression::setPattern(
const QString &pattern)
1434 if (d->pattern == pattern)
1438 d->pattern = pattern;
1442
1443
1444
1445
1446QRegularExpression::PatternOptions QRegularExpression::patternOptions()
const
1448 return d->patternOptions;
1452
1453
1454
1455
1456
1457void QRegularExpression::setPatternOptions(PatternOptions options)
1459 if (d->patternOptions == options)
1463 d->patternOptions = options;
1467
1468
1469
1470
1471
1472
1473
1474int QRegularExpression::captureCount()
const
1478 return d->capturingCount;
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506QStringList QRegularExpression::namedCaptureGroups()
const
1509 return QStringList();
1516 PCRE2_SPTR16 *namedCapturingTable;
1517 unsigned int namedCapturingTableEntryCount;
1518 unsigned int namedCapturingTableEntrySize;
1520 pcre2_pattern_info_16(d->compiledPattern, PCRE2_INFO_NAMETABLE, &namedCapturingTable);
1521 pcre2_pattern_info_16(d->compiledPattern, PCRE2_INFO_NAMECOUNT, &namedCapturingTableEntryCount);
1522 pcre2_pattern_info_16(d->compiledPattern, PCRE2_INFO_NAMEENTRYSIZE, &namedCapturingTableEntrySize);
1525 QStringList result(d->capturingCount + 1);
1527 for (
unsigned int i = 0; i < namedCapturingTableEntryCount; ++i) {
1528 const auto currentNamedCapturingTableRow =
1529 reinterpret_cast<
const char16_t *>(namedCapturingTable) + namedCapturingTableEntrySize * i;
1531 const int index = *currentNamedCapturingTableRow;
1532 result[index] = QStringView(currentNamedCapturingTableRow + 1).toString();
1539
1540
1541
1542
1543
1544
1545bool QRegularExpression::isValid()
const
1547 d.data()->compilePattern();
1548 return d->compiledPattern;
1552
1553
1554
1555
1556
1557QString QRegularExpression::errorString()
const
1559 d.data()->compilePattern();
1561 QString errorString;
1562 int errorStringLength;
1564 errorString.resize(errorString.size() + 64);
1565 errorStringLength = pcre2_get_error_message_16(d->errorCode,
1566 reinterpret_cast<ushort *>(errorString.data()),
1567 errorString.size());
1568 }
while (errorStringLength < 0);
1569 errorString.resize(errorStringLength);
1571#ifdef QT_NO_TRANSLATION
1574 return QCoreApplication::translate(
"QRegularExpression", std::move(errorString).toLatin1().constData());
1577#ifdef QT_NO_TRANSLATION
1578 return u"no error"_s;
1580 return QCoreApplication::translate(
"QRegularExpression",
"no error");
1585
1586
1587
1588
1589
1590
1591qsizetype QRegularExpression::patternErrorOffset()
const
1593 d.data()->compilePattern();
1594 return d->errorOffset;
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607QRegularExpressionMatch QRegularExpression::match(
const QString &subject,
1609 MatchType matchType,
1610 MatchOptions matchOptions)
const
1612 d.data()->compilePattern();
1613 auto priv =
new QRegularExpressionMatchPrivate(*
this,
1615 QStringView(subject),
1618 d->doMatch(priv, offset);
1619 return QRegularExpressionMatch(*priv);
1622#if QT_DEPRECATED_SINCE(6
, 8
)
1624
1625
1626
1627
1628
1629
1630QRegularExpressionMatch QRegularExpression::match(QStringView subjectView,
1632 MatchType matchType,
1633 MatchOptions matchOptions)
const
1635 return matchView(subjectView, offset, matchType, matchOptions);
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655QRegularExpressionMatch QRegularExpression::matchView(QStringView subjectView,
1657 MatchType matchType,
1658 MatchOptions matchOptions)
const
1660 d.data()->compilePattern();
1661 auto priv =
new QRegularExpressionMatchPrivate(*
this,
1666 d->doMatch(priv, offset);
1667 return QRegularExpressionMatch(*priv);
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681QRegularExpressionMatchIterator QRegularExpression::globalMatch(
const QString &subject,
1683 MatchType matchType,
1684 MatchOptions matchOptions)
const
1686 QRegularExpressionMatchIteratorPrivate *priv =
1687 new QRegularExpressionMatchIteratorPrivate(*
this,
1690 match(subject, offset, matchType, matchOptions));
1692 return QRegularExpressionMatchIterator(*priv);
1695#if QT_DEPRECATED_SINCE(6
, 8
)
1697
1698
1699
1700
1701
1702
1703QRegularExpressionMatchIterator QRegularExpression::globalMatch(QStringView subjectView,
1705 MatchType matchType,
1706 MatchOptions matchOptions)
const
1708 return globalMatchView(subjectView, offset, matchType, matchOptions);
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730QRegularExpressionMatchIterator QRegularExpression::globalMatchView(QStringView subjectView,
1732 MatchType matchType,
1733 MatchOptions matchOptions)
const
1735 QRegularExpressionMatchIteratorPrivate *priv =
1736 new QRegularExpressionMatchIteratorPrivate(*
this,
1739 matchView(subjectView, offset, matchType, matchOptions));
1741 return QRegularExpressionMatchIterator(*priv);
1745
1746
1747
1748
1749
1750
1751
1752void QRegularExpression::optimize()
const
1754 d.data()->compilePattern();
1758
1759
1760
1761
1762
1763
1764
1765
1767 const QRegularExpression &rhs)
noexcept
1769 return (lhs.d == rhs.d) ||
1770 (lhs.d->pattern == rhs.d->pattern && lhs.d->patternOptions == rhs.d->patternOptions);
1773
1774
1775
1776
1777
1778
1779
1780
1781
1784
1785
1786
1787
1788
1789
1790
1793
1794
1795
1796
1797
1798
1799size_t qHash(
const QRegularExpression &key, size_t seed)
noexcept
1801 return qHashMulti(seed, key.d->pattern, key.d->patternOptions);
1805
1806
1807
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829QString QRegularExpression::escape(QStringView str)
1832 const qsizetype count = str.size();
1833 result.reserve(count * 2);
1837 for (qsizetype i = 0; i < count; ++i) {
1838 const QChar current = str.at(i);
1840 if (current == QChar::Null) {
1844 result.append(u'\\');
1845 result.append(u'0');
1846 }
else if ((current < u'a' || current > u'z') &&
1847 (current < u'A' || current > u'Z') &&
1848 (current < u'0' || current > u'9') &&
1850 result.append(u'\\');
1851 result.append(current);
1852 if (current.isHighSurrogate() && i < (count - 1))
1853 result.append(str.at(++i));
1855 result.append(current);
1864
1865
1866
1867
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951QString QRegularExpression::wildcardToRegularExpression(QStringView pattern, WildcardConversionOptions options)
1953 const qsizetype wclen = pattern.size();
1955 rx.reserve(wclen + wclen / 16);
1957 const QChar *wc = pattern.data();
1959 struct GlobSettings {
1960 char16_t nativePathSeparator;
1961 QStringView starEscape;
1962 QStringView questionMarkEscape;
1965 const GlobSettings settings = [options]() {
1966 if (options.testFlag(NonPathWildcardConversion)) {
1967 return GlobSettings{ u'\0', u".*", u"." };
1970 return GlobSettings{ u'\\', u"[^/\\\\]*", u"[^/\\\\]" };
1972 return GlobSettings{ u'/', u"[^/]*", u"[^/]" };
1982 const QChar c = wc[i++];
1983 switch (c.unicode()) {
1985 rx += settings.starEscape;
1987 while (i < wclen && wc[i] == u'*')
1991 rx += settings.questionMarkEscape;
1999 if (options.testFlag(NonPathWildcardConversion))
2005 if (options.testFlag(NonPathWildcardConversion))
2027 if (wc[i] == u'!') {
2032 if (i < wclen && wc[i] == u']')
2035 while (i < wclen && wc[i] != u']') {
2036 if (!options.testFlag(NonPathWildcardConversion)) {
2040 if (wc[i] == u'/' || wc[i] == settings.nativePathSeparator)
2058 if (!(options & UnanchoredWildcardConversion))
2059 rx = anchoredPattern(rx);
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077QRegularExpression QRegularExpression::fromWildcard(QStringView pattern, Qt::CaseSensitivity cs,
2078 WildcardConversionOptions options)
2080 auto reOptions = cs == Qt::CaseSensitive ? QRegularExpression::NoPatternOption :
2081 QRegularExpression::CaseInsensitiveOption;
2082 return QRegularExpression(wildcardToRegularExpression(pattern, options), reOptions);
2086
2087
2088
2089
2092
2093
2094
2095
2096
2097QString QRegularExpression::anchoredPattern(QStringView expression)
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116QRegularExpressionMatch::QRegularExpressionMatch()
2117 : d(
new QRegularExpressionMatchPrivate(QRegularExpression(),
2120 QRegularExpression::NoMatch,
2121 QRegularExpression::NoMatchOption))
2127
2128
2129QRegularExpressionMatch::~QRegularExpressionMatch()
2133QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QRegularExpressionMatchPrivate)
2136
2137
2138
2139
2140QRegularExpressionMatch::QRegularExpressionMatch(
const QRegularExpressionMatch &match)
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2160
2161
2162
2163QRegularExpressionMatch &QRegularExpressionMatch::operator=(
const QRegularExpressionMatch &match)
2170
2171
2172
2173
2174
2175
2176
2177
2178
2181
2182
2183
2186
2187
2188QRegularExpressionMatch::QRegularExpressionMatch(QRegularExpressionMatchPrivate &dd)
2194
2195
2196
2197
2198
2199QRegularExpression QRegularExpressionMatch::regularExpression()
const
2201 return d->regularExpression;
2206
2207
2208
2209
2210
2211
2212QRegularExpression::MatchType QRegularExpressionMatch::matchType()
const
2214 return d->matchType;
2218
2219
2220
2221
2222
2223
2224QRegularExpression::MatchOptions QRegularExpressionMatch::matchOptions()
const
2226 return d->matchOptions;
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243int QRegularExpressionMatch::lastCapturedIndex()
const
2245 return d->capturedCount - 1;
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271bool QRegularExpressionMatch::hasCaptured(QAnyStringView name)
const
2273 const int nth = d->regularExpression.d->captureIndexForName(name);
2274 return hasCaptured(nth);
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299bool QRegularExpressionMatch::hasCaptured(
int nth)
const
2301 if (nth < 0 || nth > lastCapturedIndex())
2304 return d->capturedOffsets.at(nth * 2) != -1;
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319QString QRegularExpressionMatch::captured(
int nth)
const
2321 return capturedView(nth).toString();
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338QStringView QRegularExpressionMatch::capturedView(
int nth)
const
2340 if (!hasCaptured(nth))
2341 return QStringView();
2343 qsizetype start = capturedStart(nth);
2346 return QStringView();
2348 return d->subject.mid(start, capturedLength(nth));
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365QString QRegularExpressionMatch::captured(QAnyStringView name)
const
2367 if (name.isEmpty()) {
2368 qWarning(
"QRegularExpressionMatch::captured: empty capturing group name passed");
2372 return capturedView(name).toString();
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390QStringView QRegularExpressionMatch::capturedView(QAnyStringView name)
const
2392 if (name.isEmpty()) {
2393 qWarning(
"QRegularExpressionMatch::capturedView: empty capturing group name passed");
2394 return QStringView();
2396 int nth = d->regularExpression.d->captureIndexForName(name);
2398 return QStringView();
2399 return capturedView(nth);
2403
2404
2405
2406
2407
2408QStringList QRegularExpressionMatch::capturedTexts()
const
2411 texts.reserve(d->capturedCount);
2412 for (
int i = 0; i < d->capturedCount; ++i)
2413 texts << captured(i);
2418
2419
2420
2421
2422
2423
2424
2425qsizetype QRegularExpressionMatch::capturedStart(
int nth)
const
2427 if (!hasCaptured(nth))
2430 return d->capturedOffsets.at(nth * 2);
2434
2435
2436
2437
2438
2439
2440
2441qsizetype QRegularExpressionMatch::capturedLength(
int nth)
const
2444 return capturedEnd(nth) - capturedStart(nth);
2448
2449
2450
2451
2452
2453
2454qsizetype QRegularExpressionMatch::capturedEnd(
int nth)
const
2456 if (!hasCaptured(nth))
2459 return d->capturedOffsets.at(nth * 2 + 1);
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475qsizetype QRegularExpressionMatch::capturedStart(QAnyStringView name)
const
2477 if (name.isEmpty()) {
2478 qWarning(
"QRegularExpressionMatch::capturedStart: empty capturing group name passed");
2481 int nth = d->regularExpression.d->captureIndexForName(name);
2484 return capturedStart(nth);
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501qsizetype QRegularExpressionMatch::capturedLength(QAnyStringView name)
const
2503 if (name.isEmpty()) {
2504 qWarning(
"QRegularExpressionMatch::capturedLength: empty capturing group name passed");
2507 int nth = d->regularExpression.d->captureIndexForName(name);
2510 return capturedLength(nth);
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526qsizetype QRegularExpressionMatch::capturedEnd(QAnyStringView name)
const
2528 if (name.isEmpty()) {
2529 qWarning(
"QRegularExpressionMatch::capturedEnd: empty capturing group name passed");
2532 int nth = d->regularExpression.d->captureIndexForName(name);
2535 return capturedEnd(nth);
2539
2540
2541
2542
2543
2544bool QRegularExpressionMatch::hasMatch()
const
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559bool QRegularExpressionMatch::hasPartialMatch()
const
2561 return d->hasPartialMatch;
2565
2566
2567
2568
2569
2570
2571bool QRegularExpressionMatch::isValid()
const
2577
2578
2579QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(QRegularExpressionMatchIteratorPrivate &dd)
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596QRegularExpressionMatchIterator::QRegularExpressionMatchIterator()
2597 : d(
new QRegularExpressionMatchIteratorPrivate(QRegularExpression(),
2598 QRegularExpression::NoMatch,
2599 QRegularExpression::NoMatchOption,
2600 QRegularExpressionMatch()))
2605
2606
2607QRegularExpressionMatchIterator::~QRegularExpressionMatchIterator()
2611QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QRegularExpressionMatchIteratorPrivate)
2614
2615
2616
2617
2618
2619QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(
const QRegularExpressionMatchIterator &iterator)
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2639
2640
2641
2642QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(
const QRegularExpressionMatchIterator &iterator)
2649
2650
2651
2652
2653
2654
2655
2656
2657
2660
2661
2662
2665
2666
2667
2668
2669
2670
2671
2672bool QRegularExpressionMatchIterator::isValid()
const
2674 return d->next.isValid();
2678
2679
2680
2681
2682
2683bool QRegularExpressionMatchIterator::hasNext()
const
2685 return d->hasNext();
2689
2690
2691
2692
2693
2694QRegularExpressionMatch QRegularExpressionMatchIterator::peekNext()
const
2697 qWarning(
"QRegularExpressionMatchIterator::peekNext() called on an iterator already at end");
2703
2704
2705
2706
2707
2708QRegularExpressionMatch QRegularExpressionMatchIterator::next()
2711 qWarning(
"QRegularExpressionMatchIterator::next() called on an iterator already at end");
2712 return d.constData()->next;
2716 return std::exchange(d->next, d->next.d.constData()->nextMatch());
2720
2721
2722
2723
2724
2725QRegularExpression QRegularExpressionMatchIterator::regularExpression()
const
2727 return d->regularExpression;
2731
2732
2733
2734
2735
2736
2737QRegularExpression::MatchType QRegularExpressionMatchIterator::matchType()
const
2739 return d->matchType;
2743
2744
2745
2746
2747
2748
2749QRegularExpression::MatchOptions QRegularExpressionMatchIterator::matchOptions()
const
2751 return d->matchOptions;
2755
2756
2763
2764
2765
2767#ifndef QT_NO_DATASTREAM
2769
2770
2771
2772
2773
2774
2777 out << re.pattern() << quint32(re.patternOptions().toInt());
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2795 quint32 patternOptions;
2796 in >> pattern >> patternOptions;
2797 re.setPattern(pattern);
2798 re.setPatternOptions(QRegularExpression::PatternOptions::fromInt(patternOptions));
2803#ifndef QT_NO_DEBUG_STREAM
2805
2806
2807
2808
2809
2810
2811
2814 QDebugStateSaver saver(debug);
2815 debug.nospace() <<
"QRegularExpression(" << re.pattern() <<
", " << re.patternOptions() <<
')';
2820
2821
2822
2823
2824
2825
2826
2829 QDebugStateSaver saver(debug);
2832 if (patternOptions == QRegularExpression::NoPatternOption) {
2833 flags =
"NoPatternOption";
2836 if (patternOptions & QRegularExpression::CaseInsensitiveOption)
2837 flags.append(
"CaseInsensitiveOption|");
2838 if (patternOptions & QRegularExpression::DotMatchesEverythingOption)
2839 flags.append(
"DotMatchesEverythingOption|");
2840 if (patternOptions & QRegularExpression::MultilineOption)
2841 flags.append(
"MultilineOption|");
2842 if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption)
2843 flags.append(
"ExtendedPatternSyntaxOption|");
2844 if (patternOptions & QRegularExpression::InvertedGreedinessOption)
2845 flags.append(
"InvertedGreedinessOption|");
2846 if (patternOptions & QRegularExpression::DontCaptureOption)
2847 flags.append(
"DontCaptureOption|");
2848 if (patternOptions & QRegularExpression::UseUnicodePropertiesOption)
2849 flags.append(
"UseUnicodePropertiesOption|");
2853 debug.nospace() <<
"QRegularExpression::PatternOptions(" << flags <<
')';
2858
2859
2860
2861
2862
2863
2864
2867 QDebugStateSaver saver(debug);
2868 debug.nospace() <<
"QRegularExpressionMatch(";
2870 if (!match.isValid()) {
2871 debug <<
"Invalid)";
2877 if (match.hasMatch()) {
2878 debug <<
", has match: ";
2879 for (
int i = 0; i <= match.lastCapturedIndex(); ++i) {
2881 <<
":(" << match.capturedStart(i) <<
", " << match.capturedEnd(i)
2882 <<
", " << match.captured(i) <<
')';
2883 if (i < match.lastCapturedIndex())
2886 }
else if (match.hasPartialMatch()) {
2887 debug <<
", has partial match: ("
2888 << match.capturedStart(0) <<
", "
2889 << match.capturedEnd(0) <<
", "
2890 << match.captured(0) <<
')';
2892 debug <<
", no match";
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2941static const char *pcreCompileErrorCodes[] =
2943 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no error"),
2944 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\ at end of pattern"),
2945 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c at end of pattern"),
2946 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized character follows \\"),
2947 QT_TRANSLATE_NOOP(
"QRegularExpression",
"numbers out of order in {} quantifier"),
2948 QT_TRANSLATE_NOOP(
"QRegularExpression",
"number too big in {} quantifier"),
2949 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing terminating ] for character class"),
2950 QT_TRANSLATE_NOOP(
"QRegularExpression",
"escape sequence is invalid in character class"),
2951 QT_TRANSLATE_NOOP(
"QRegularExpression",
"range out of order in character class"),
2952 QT_TRANSLATE_NOOP(
"QRegularExpression",
"quantifier does not follow a repeatable item"),
2953 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unexpected repeat"),
2954 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized character after (? or (?-"),
2955 QT_TRANSLATE_NOOP(
"QRegularExpression",
"POSIX named classes are supported only within a class"),
2956 QT_TRANSLATE_NOOP(
"QRegularExpression",
"POSIX collating elements are not supported"),
2957 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing closing parenthesis"),
2958 QT_TRANSLATE_NOOP(
"QRegularExpression",
"reference to non-existent subpattern"),
2959 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern passed as NULL"),
2960 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognised compile-time option bit(s)"),
2961 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing ) after (?# comment"),
2962 QT_TRANSLATE_NOOP(
"QRegularExpression",
"parentheses are too deeply nested"),
2963 QT_TRANSLATE_NOOP(
"QRegularExpression",
"regular expression is too large"),
2964 QT_TRANSLATE_NOOP(
"QRegularExpression",
"failed to allocate heap memory"),
2965 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unmatched closing parenthesis"),
2966 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: code overflow"),
2967 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing closing parenthesis for condition"),
2968 QT_TRANSLATE_NOOP(
"QRegularExpression",
"lookbehind assertion is not fixed length"),
2969 QT_TRANSLATE_NOOP(
"QRegularExpression",
"a relative value of zero is not allowed"),
2970 QT_TRANSLATE_NOOP(
"QRegularExpression",
"conditional subpattern contains more than two branches"),
2971 QT_TRANSLATE_NOOP(
"QRegularExpression",
"assertion expected after (?( or (?(?C)"),
2972 QT_TRANSLATE_NOOP(
"QRegularExpression",
"digit expected after (?+ or (?-"),
2973 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unknown POSIX class name"),
2974 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error in pcre2_study(): should not occur"),
2975 QT_TRANSLATE_NOOP(
"QRegularExpression",
"this version of PCRE2 does not have Unicode support"),
2976 QT_TRANSLATE_NOOP(
"QRegularExpression",
"parentheses are too deeply nested (stack check)"),
2977 QT_TRANSLATE_NOOP(
"QRegularExpression",
"character code point value in \\x{} or \\o{} is too large"),
2978 QT_TRANSLATE_NOOP(
"QRegularExpression",
"lookbehind is too complicated"),
2979 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\C is not allowed in a lookbehind assertion in UTF-" "16" " mode"),
2980 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2 does not support \\F, \\L, \\l, \\N{name}, \\U, or \\u"),
2981 QT_TRANSLATE_NOOP(
"QRegularExpression",
"number after (?C is greater than 255"),
2982 QT_TRANSLATE_NOOP(
"QRegularExpression",
"closing parenthesis for (?C expected"),
2983 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid escape sequence in (*VERB) name"),
2984 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized character after (?P"),
2985 QT_TRANSLATE_NOOP(
"QRegularExpression",
"syntax error in subpattern name (missing terminator?)"),
2986 QT_TRANSLATE_NOOP(
"QRegularExpression",
"two named subpatterns have the same name (PCRE2_DUPNAMES not set)"),
2987 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name must start with a non-digit"),
2988 QT_TRANSLATE_NOOP(
"QRegularExpression",
"this version of PCRE2 does not have support for \\P, \\p, or \\X"),
2989 QT_TRANSLATE_NOOP(
"QRegularExpression",
"malformed \\P or \\p sequence"),
2990 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unknown property name after \\P or \\p"),
2991 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name is too long (maximum " "32" " code units)"),
2992 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many named subpatterns (maximum " "10000" ")"),
2993 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid range in character class"),
2994 QT_TRANSLATE_NOOP(
"QRegularExpression",
"octal value is greater than \\377 in 8-bit non-UTF-8 mode"),
2995 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: overran compiling workspace"),
2996 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: previously-checked referenced subpattern not found"),
2997 QT_TRANSLATE_NOOP(
"QRegularExpression",
"DEFINE subpattern contains more than one branch"),
2998 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing opening brace after \\o"),
2999 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown newline setting"),
3000 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number"),
3001 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(?R (recursive pattern call) must be followed by a closing parenthesis"),
3002 QT_TRANSLATE_NOOP(
"QRegularExpression",
"obsolete error (should not occur)"),
3003 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(*VERB) not recognized or malformed"),
3004 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern number is too big"),
3005 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name expected"),
3006 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: parsed pattern overflow"),
3007 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-octal character in \\o{} (closing brace missing?)"),
3008 QT_TRANSLATE_NOOP(
"QRegularExpression",
"different names for subpatterns of the same number are not allowed"),
3009 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(*MARK) must have an argument"),
3010 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-hex character in \\x{} (closing brace missing?)"),
3011 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c must be followed by a printable ASCII character"),
3012 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c must be followed by a letter or one of [\\]^_?"),
3013 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\k is not followed by a braced, angle-bracketed, or quoted name"),
3014 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown meta code in check_lookbehinds()"),
3015 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\N is not supported in a class"),
3016 QT_TRANSLATE_NOOP(
"QRegularExpression",
"callout string is too long"),
3017 QT_TRANSLATE_NOOP(
"QRegularExpression",
"disallowed Unicode code point (>= 0xd800 && <= 0xdfff)"),
3018 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using UTF is disabled by the application"),
3019 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using UCP is disabled by the application"),
3020 QT_TRANSLATE_NOOP(
"QRegularExpression",
"name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)"),
3021 QT_TRANSLATE_NOOP(
"QRegularExpression",
"character code point value in \\u.... sequence is too large"),
3022 QT_TRANSLATE_NOOP(
"QRegularExpression",
"digits missing in \\x{} or \\o{} or \\N{U+}"),
3023 QT_TRANSLATE_NOOP(
"QRegularExpression",
"syntax error or number too big in (?(VERSION condition"),
3024 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown opcode in auto_possessify()"),
3025 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing terminating delimiter for callout with string argument"),
3026 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized string delimiter follows (?C"),
3027 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using \\C is disabled by the application"),
3028 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(?| and/or (?J: or (?x: parentheses are too deeply nested"),
3029 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using \\C is disabled in this PCRE2 library"),
3030 QT_TRANSLATE_NOOP(
"QRegularExpression",
"regular expression is too complicated"),
3031 QT_TRANSLATE_NOOP(
"QRegularExpression",
"lookbehind assertion is too long"),
3032 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern string is longer than the limit set by the application"),
3033 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown code in parsed pattern"),
3034 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: bad code value in parsed_skip()"),
3035 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES is not allowed in UTF-16 mode"),
3036 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid option bits with PCRE2_LITERAL"),
3037 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\N{U+dddd} is supported only in Unicode (UTF) mode"),
3038 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid hyphen in option setting"),
3039 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(*alpha_assertion) not recognized"),
3040 QT_TRANSLATE_NOOP(
"QRegularExpression",
"script runs require Unicode support, which this version of PCRE2 does not have"),
3041 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many capturing groups (maximum 65535)"),
3042 QT_TRANSLATE_NOOP(
"QRegularExpression",
"atomic assertion expected after (?( or (?(?C)"),
3043 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no error"),
3044 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no match"),
3045 QT_TRANSLATE_NOOP(
"QRegularExpression",
"partial match"),
3046 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 1 byte missing at end"),
3047 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 2 bytes missing at end"),
3048 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 3 bytes missing at end"),
3049 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 4 bytes missing at end"),
3050 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 5 bytes missing at end"),
3051 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 2 top bits not 0x80"),
3052 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 3 top bits not 0x80"),
3053 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 4 top bits not 0x80"),
3054 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 5 top bits not 0x80"),
3055 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 6 top bits not 0x80"),
3056 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 5-byte character is not allowed (RFC 3629)"),
3057 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 6-byte character is not allowed (RFC 3629)"),
3058 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: code points greater than 0x10ffff are not defined"),
3059 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: code points 0xd800-0xdfff are not defined"),
3060 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 2-byte sequence"),
3061 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 3-byte sequence"),
3062 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 4-byte sequence"),
3063 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 5-byte sequence"),
3064 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 6-byte sequence"),
3065 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: isolated byte with 0x80 bit set"),
3066 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: illegal byte (0xfe or 0xff)"),
3067 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: missing low surrogate at end"),
3068 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: invalid low surrogate"),
3069 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: isolated low surrogate"),
3070 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-32 error: code points 0xd800-0xdfff are not defined"),
3071 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-32 error: code points greater than 0x10ffff are not defined"),
3072 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad data value"),
3073 QT_TRANSLATE_NOOP(
"QRegularExpression",
"patterns do not all use the same character tables"),
3074 QT_TRANSLATE_NOOP(
"QRegularExpression",
"magic number missing"),
3075 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern compiled in wrong mode: 8/16/32-bit error"),
3076 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad offset value"),
3077 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad option value"),
3078 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid replacement string"),
3079 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad offset into UTF string"),
3080 QT_TRANSLATE_NOOP(
"QRegularExpression",
"callout error code"),
3081 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid data in workspace for DFA restart"),
3082 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too much recursion for DFA matching"),
3083 QT_TRANSLATE_NOOP(
"QRegularExpression",
"backreference condition or recursion test is not supported for DFA matching"),
3084 QT_TRANSLATE_NOOP(
"QRegularExpression",
"function is not supported for DFA matching"),
3085 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern contains an item that is not supported for DFA matching"),
3086 QT_TRANSLATE_NOOP(
"QRegularExpression",
"workspace size exceeded in DFA matching"),
3087 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error - pattern overwritten?"),
3088 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad JIT option"),
3089 QT_TRANSLATE_NOOP(
"QRegularExpression",
"JIT stack limit reached"),
3090 QT_TRANSLATE_NOOP(
"QRegularExpression",
"match limit exceeded"),
3091 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no more memory"),
3092 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unknown substring"),
3093 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-unique substring name"),
3094 QT_TRANSLATE_NOOP(
"QRegularExpression",
"NULL argument passed"),
3095 QT_TRANSLATE_NOOP(
"QRegularExpression",
"nested recursion at the same subject position"),
3096 QT_TRANSLATE_NOOP(
"QRegularExpression",
"matching depth limit exceeded"),
3097 QT_TRANSLATE_NOOP(
"QRegularExpression",
"requested value is not available"),
3098 QT_TRANSLATE_NOOP(
"QRegularExpression",
"requested value is not set"),
3099 QT_TRANSLATE_NOOP(
"QRegularExpression",
"offset limit set without PCRE2_USE_OFFSET_LIMIT"),
3100 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad escape sequence in replacement string"),
3101 QT_TRANSLATE_NOOP(
"QRegularExpression",
"expected closing curly bracket in replacement string"),
3102 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad substitution in replacement string"),
3103 QT_TRANSLATE_NOOP(
"QRegularExpression",
"match with end before start or start moved backwards is not supported"),
3104 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many replacements (more than INT_MAX)"),
3105 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad serialized data"),
3106 QT_TRANSLATE_NOOP(
"QRegularExpression",
"heap limit exceeded"),
3107 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid syntax"),
3108 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error - duplicate substitution match"),
3109 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2_MATCH_INVALID_UTF is not supported for DFA matching"),
3110 QT_TRANSLATE_NOOP(
"QRegularExpression",
"INTERNAL ERROR: invalid substring offset")
QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match)
Writes the match object match into the debug object debug for debugging purposes.
QDataStream & operator<<(QDataStream &out, const QRegularExpression &re)
Writes the regular expression re to stream out.
QDataStream & operator>>(QDataStream &in, QRegularExpression &re)
Reads a regular expression from stream in into re.
QDebug operator<<(QDebug debug, const QRegularExpression &re)
Writes the regular expression re into the debug object debug for debugging purposes.
QRegularExpressionMatchIteratorRangeBasedForIterator(const QRegularExpressionMatchIterator &iterator)
QDebug operator<<(QDebug debug, QDir::Filters filters)
static pcre2_jit_stack_16 * qtPcreCallback(void *)
static int convertToPcreOptions(QRegularExpression::PatternOptions patternOptions)
bool comparesEqual(const QRegularExpression &lhs, const QRegularExpression &rhs) noexcept
Q_DECL_COLD_FUNCTION void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *cls, const char *method)
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)
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
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
QList< qsizetype > capturedOffsets
QRegularExpressionMatch nextMatch() const
const QRegularExpression regularExpression
const QStringView subject
QRegularExpressionPrivate(const QRegularExpressionPrivate &other)
int captureIndexForName(QAnyStringView name) const
pcre2_code_16 * compiledPattern
void doMatch(QRegularExpressionMatchPrivate *priv, qsizetype offset, CheckSubjectStringOption checkSubjectStringOption=CheckSubjectString, const QRegularExpressionMatchPrivate *previous=nullptr) const
void cleanCompiledPattern()
QRegularExpressionPrivate()
~QRegularExpressionPrivate()
QRegularExpression::PatternOptions patternOptions