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
438
439
440
441
442
443
444
445
446
447
448
449
450
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
491
492
493
494
495
496
497
498
499
500
501
502
503
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
543
544
545
546
547
548
549
550
551
552
553
554
555
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
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
667
668
673 if (patternOptions & QRegularExpression::CaseInsensitiveOption)
674 options |= PCRE2_CASELESS;
675 if (patternOptions & QRegularExpression::DotMatchesEverythingOption)
676 options |= PCRE2_DOTALL;
677 if (patternOptions & QRegularExpression::MultilineOption)
678 options |= PCRE2_MULTILINE;
679 if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption)
680 options |= PCRE2_EXTENDED;
681 if (patternOptions & QRegularExpression::InvertedGreedinessOption)
682 options |= PCRE2_UNGREEDY;
683 if (patternOptions & QRegularExpression::DontCaptureOption)
684 options |= PCRE2_NO_AUTO_CAPTURE;
685 if (patternOptions & QRegularExpression::UseUnicodePropertiesOption)
686 options |= PCRE2_UCP;
692
693
698 if (matchOptions & QRegularExpression::AnchorAtOffsetMatchOption)
699 options |= PCRE2_ANCHORED;
700 if (matchOptions & QRegularExpression::DontCheckSubjectStringMatchOption)
701 options |= PCRE2_NO_UTF_CHECK;
752 const QString &subjectStorage,
754 QRegularExpression::MatchType matchType,
755 QRegularExpression::MatchOptions matchOptions);
784 QRegularExpression::MatchType matchType,
785 QRegularExpression::MatchOptions matchOptions,
786 const QRegularExpressionMatch &next);
796
797
798
799
800
801
805 if (pattern.isValidUtf16()) {
806 qWarning(
"%s::%s(): called on an invalid QRegularExpression object "
807 "(pattern is '%ls')", cls, method, qUtf16Printable(pattern));
809 qWarning(
"%s::%s(): called on an invalid QRegularExpression object",
815
816
817QRegularExpression::QRegularExpression(QRegularExpressionPrivate &dd)
823
824
840
841
848
849
850
851
852
853
854
855
871
872
884
885
888 const QMutexLocker lock(&mutex);
896 int options = convertToPcreOptions(patternOptions);
897 options |= PCRE2_UTF;
899 PCRE2_SIZE patternErrorOffset;
900 compiledPattern = pcre2_compile_16(
reinterpret_cast<PCRE2_SPTR16>(pattern.constData()),
908 errorOffset = qsizetype(patternErrorOffset);
920
921
929 unsigned int patternNewlineSetting;
930 if (pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NEWLINE, &patternNewlineSetting) != 0) {
932 pcre2_config_16(PCRE2_CONFIG_NEWLINE, &patternNewlineSetting);
936 (patternNewlineSetting == PCRE2_NEWLINE_ANY) ||
937 (patternNewlineSetting == PCRE2_NEWLINE_ANYCRLF);
939 unsigned int hasJOptionChanged;
940 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_JCHANGED, &hasJOptionChanged);
941 if (Q_UNLIKELY(hasJOptionChanged)) {
942 qWarning(
"QRegularExpressionPrivate::getPatternInfo(): the pattern '%ls'\n is using the (?J) option; duplicate capturing group names are not supported by Qt",
943 qUtf16Printable(pattern));
949
950
951
953struct PcreJitStackFree
955 void operator()(pcre2_jit_stack_16 *stack)
958 pcre2_jit_stack_free_16(stack);
961Q_CONSTINIT
static thread_local std::unique_ptr<pcre2_jit_stack_16, PcreJitStackFree> jitStacks;
965
966
969 return jitStacks.get();
973
974
977 QByteArray jitEnvironment = qgetenv(
"QT_ENABLE_REGEXP_JIT");
978 if (!jitEnvironment.isEmpty()) {
980 int enableJit = jitEnvironment.toInt(&ok);
981 return ok ? (enableJit != 0) :
true;
986#elif defined(Q_OS_MACOS) && !defined(QT_BOOTSTRAPPED)
987 return !qt_mac_runningUnderRosetta();
994
995
996
997
998
999
1000
1001
1011 pcre2_jit_compile_16(
compiledPattern, PCRE2_JIT_COMPLETE | PCRE2_JIT_PARTIAL_SOFT | PCRE2_JIT_PARTIAL_HARD);
1015
1016
1017
1018
1019
1022 Q_ASSERT(!name.isEmpty());
1028 PCRE2_SPTR16 *namedCapturingTable;
1029 unsigned int namedCapturingTableEntryCount;
1030 unsigned int namedCapturingTableEntrySize;
1032 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMETABLE, &namedCapturingTable);
1033 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMECOUNT, &namedCapturingTableEntryCount);
1034 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_NAMEENTRYSIZE, &namedCapturingTableEntrySize);
1036 for (
unsigned int i = 0; i < namedCapturingTableEntryCount; ++i) {
1037 const auto currentNamedCapturingTableRow =
1038 reinterpret_cast<
const char16_t *>(namedCapturingTable) + namedCapturingTableEntrySize * i;
1040 if (name == (currentNamedCapturingTableRow + 1)) {
1041 const int index = *currentNamedCapturingTableRow;
1050
1051
1052
1053
1054
1055
1057 PCRE2_SPTR16 subject, qsizetype length,
1058 qsizetype startOffset,
int options,
1059 pcre2_match_data_16 *matchData,
1060 pcre2_match_context_16 *matchContext)
1062 int result = pcre2_match_16(code, subject, length,
1063 startOffset, options, matchData, matchContext);
1065 if (result == PCRE2_ERROR_JIT_STACKLIMIT && !jitStacks) {
1068 jitStacks.reset(pcre2_jit_stack_create_16(32 * 1024, 512 * 1024, NULL));
1070 result = pcre2_match_16(code, subject, length,
1071 startOffset, options, matchData, matchContext);
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1111 Q_ASSERT(priv != previous);
1113 const qsizetype subjectLength = priv->subject.size();
1116 offset += subjectLength;
1118 if (offset < 0 || offset > subjectLength)
1122 qtWarnAboutInvalidRegularExpression(pattern,
"QRegularExpressionPrivate",
"doMatch");
1127 if (priv->matchType == QRegularExpression::NoMatch) {
1132 int pcreOptions = convertToPcreOptions(priv->matchOptions);
1134 if (priv->matchType == QRegularExpression::PartialPreferCompleteMatch)
1135 pcreOptions |= PCRE2_PARTIAL_SOFT;
1136 else if (priv->matchType == QRegularExpression::PartialPreferFirstMatch)
1137 pcreOptions |= PCRE2_PARTIAL_HARD;
1140 pcreOptions |= PCRE2_NO_UTF_CHECK;
1142 bool previousMatchWasEmpty =
false;
1144 (previous->capturedOffsets.at(0) == previous->capturedOffsets.at(1))) {
1145 previousMatchWasEmpty =
true;
1148 pcre2_match_context_16 *matchContext = pcre2_match_context_create_16(
nullptr);
1149 pcre2_jit_stack_assign_16(matchContext, &
qtPcreCallback,
nullptr);
1150 pcre2_match_data_16 *matchData = pcre2_match_data_create_from_pattern_16(
compiledPattern,
nullptr);
1156 const char16_t dummySubject = 0;
1157 const char16_t *
const subjectUtf16 = [&]()
1159 const auto subjectUtf16 = priv->subject.utf16();
1161 return subjectUtf16;
1162 Q_ASSERT(subjectLength == 0);
1163 return &dummySubject;
1168 if (!previousMatchWasEmpty) {
1169 result = safe_pcre2_match_16(compiledPattern,
1170 reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
1171 offset, pcreOptions,
1172 matchData, matchContext);
1174 result = safe_pcre2_match_16(compiledPattern,
1175 reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
1176 offset, pcreOptions | PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED,
1177 matchData, matchContext);
1179 if (result == PCRE2_ERROR_NOMATCH) {
1183 && offset < subjectLength
1184 && subjectUtf16[offset - 1] == u'\r'
1185 && subjectUtf16[offset] == u'\n') {
1187 }
else if (offset < subjectLength
1188 && QChar::isLowSurrogate(subjectUtf16[offset])) {
1192 result = safe_pcre2_match_16(compiledPattern,
1193 reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
1194 offset, pcreOptions,
1195 matchData, matchContext);
1199#ifdef QREGULAREXPRESSION_DEBUG
1200 qDebug() <<
"Matching" << pattern <<
"against" << subject
1201 <<
"offset" << offset
1202 << priv->matchType << priv->matchOptions << previousMatchWasEmpty
1203 <<
"result" << result;
1207 Q_ASSERT(result != 0);
1214 priv->capturedOffsets.resize(result * 2);
1218 priv
->isValid = (result == PCRE2_ERROR_NOMATCH || result == PCRE2_ERROR_PARTIAL);
1220 if (result == PCRE2_ERROR_PARTIAL) {
1224 priv->capturedOffsets.resize(2);
1228 priv->capturedOffsets.clear();
1234 PCRE2_SIZE *ovector = pcre2_get_ovector_pointer_16(matchData);
1235 qsizetype *
const capturedOffsets = priv->capturedOffsets.data();
1241 static_assert(qsizetype(PCRE2_UNSET) == qsizetype(-1),
"Internal error: PCRE2 changed its API");
1244 capturedOffsets[i] = qsizetype(ovector[i]);
1257 if (result == PCRE2_ERROR_PARTIAL) {
1258 unsigned int maximumLookBehind;
1259 pcre2_pattern_info_16(
compiledPattern, PCRE2_INFO_MAXLOOKBEHIND, &maximumLookBehind);
1260 capturedOffsets[0] -= maximumLookBehind;
1264 pcre2_match_data_free_16(matchData);
1265 pcre2_match_context_free_16(matchContext);
1269
1270
1272 const QString &subjectStorage,
1273 QStringView subject,
1274 QRegularExpression::MatchType matchType,
1275 QRegularExpression::MatchOptions matchOptions)
1285
1286
1292 auto nextPrivate =
new QRegularExpressionMatchPrivate(regularExpression,
1302 regularExpression.d->doMatch(nextPrivate,
1303 capturedOffsets.at(1),
1304 QRegularExpressionPrivate::DontCheckSubjectString,
1306 return QRegularExpressionMatch(*nextPrivate);
1310
1311
1313 QRegularExpression::MatchType matchType,
1314 QRegularExpression::MatchOptions matchOptions,
1315 const QRegularExpressionMatch &next)
1323
1324
1327 return next.isValid() && (next.hasMatch() || next.hasPartialMatch());
1333
1334
1335
1336
1337
1338QRegularExpression::QRegularExpression()
1339 : d(
new QRegularExpressionPrivate)
1344
1345
1346
1347
1348
1349QRegularExpression::QRegularExpression(
const QString &pattern, PatternOptions options)
1350 : d(
new QRegularExpressionPrivate)
1352 d->pattern = pattern;
1353 d->patternOptions = options;
1357
1358
1359
1360
1361QRegularExpression::QRegularExpression(
const QRegularExpression &re)
noexcept =
default;
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1378
1379
1380QRegularExpression::~QRegularExpression()
1384QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QRegularExpressionPrivate)
1387
1388
1389
1390QRegularExpression &QRegularExpression::operator=(
const QRegularExpression &re)
noexcept =
default;
1393
1394
1395
1398
1399
1400
1401
1402QString QRegularExpression::pattern()
const
1408
1409
1410
1411
1412
1413void QRegularExpression::setPattern(
const QString &pattern)
1415 if (d->pattern == pattern)
1419 d->pattern = pattern;
1423
1424
1425
1426
1427QRegularExpression::PatternOptions QRegularExpression::patternOptions()
const
1429 return d->patternOptions;
1433
1434
1435
1436
1437
1438void QRegularExpression::setPatternOptions(PatternOptions options)
1440 if (d->patternOptions == options)
1444 d->patternOptions = options;
1448
1449
1450
1451
1452
1453
1454
1455int QRegularExpression::captureCount()
const
1459 return d->capturingCount;
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487QStringList QRegularExpression::namedCaptureGroups()
const
1490 return QStringList();
1497 PCRE2_SPTR16 *namedCapturingTable;
1498 unsigned int namedCapturingTableEntryCount;
1499 unsigned int namedCapturingTableEntrySize;
1501 pcre2_pattern_info_16(d->compiledPattern, PCRE2_INFO_NAMETABLE, &namedCapturingTable);
1502 pcre2_pattern_info_16(d->compiledPattern, PCRE2_INFO_NAMECOUNT, &namedCapturingTableEntryCount);
1503 pcre2_pattern_info_16(d->compiledPattern, PCRE2_INFO_NAMEENTRYSIZE, &namedCapturingTableEntrySize);
1506 QStringList result(d->capturingCount + 1);
1508 for (
unsigned int i = 0; i < namedCapturingTableEntryCount; ++i) {
1509 const auto currentNamedCapturingTableRow =
1510 reinterpret_cast<
const char16_t *>(namedCapturingTable) + namedCapturingTableEntrySize * i;
1512 const int index = *currentNamedCapturingTableRow;
1513 result[index] = QStringView(currentNamedCapturingTableRow + 1).toString();
1520
1521
1522
1523
1524
1525
1526bool QRegularExpression::isValid()
const
1528 d.data()->compilePattern();
1529 return d->compiledPattern;
1533
1534
1535
1536
1537
1538QString QRegularExpression::errorString()
const
1540 d.data()->compilePattern();
1542 QString errorString;
1543 int errorStringLength;
1545 errorString.resize(errorString.size() + 64);
1546 errorStringLength = pcre2_get_error_message_16(d->errorCode,
1547 reinterpret_cast<ushort *>(errorString.data()),
1548 errorString.size());
1549 }
while (errorStringLength < 0);
1550 errorString.resize(errorStringLength);
1552#ifdef QT_NO_TRANSLATION
1555 return QCoreApplication::translate(
"QRegularExpression", std::move(errorString).toLatin1().constData());
1558#ifdef QT_NO_TRANSLATION
1559 return u"no error"_s;
1561 return QCoreApplication::translate(
"QRegularExpression",
"no error");
1566
1567
1568
1569
1570
1571
1572qsizetype QRegularExpression::patternErrorOffset()
const
1574 d.data()->compilePattern();
1575 return d->errorOffset;
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588QRegularExpressionMatch QRegularExpression::match(
const QString &subject,
1590 MatchType matchType,
1591 MatchOptions matchOptions)
const
1593 d.data()->compilePattern();
1594 auto priv =
new QRegularExpressionMatchPrivate(*
this,
1596 QStringView(subject),
1599 d->doMatch(priv, offset);
1600 return QRegularExpressionMatch(*priv);
1603#if QT_DEPRECATED_SINCE(6
, 8
)
1605
1606
1607
1608
1609
1610
1611QRegularExpressionMatch QRegularExpression::match(QStringView subjectView,
1613 MatchType matchType,
1614 MatchOptions matchOptions)
const
1616 return matchView(subjectView, offset, matchType, matchOptions);
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636QRegularExpressionMatch QRegularExpression::matchView(QStringView subjectView,
1638 MatchType matchType,
1639 MatchOptions matchOptions)
const
1641 d.data()->compilePattern();
1642 auto priv =
new QRegularExpressionMatchPrivate(*
this,
1647 d->doMatch(priv, offset);
1648 return QRegularExpressionMatch(*priv);
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662QRegularExpressionMatchIterator QRegularExpression::globalMatch(
const QString &subject,
1664 MatchType matchType,
1665 MatchOptions matchOptions)
const
1667 QRegularExpressionMatchIteratorPrivate *priv =
1668 new QRegularExpressionMatchIteratorPrivate(*
this,
1671 match(subject, offset, matchType, matchOptions));
1673 return QRegularExpressionMatchIterator(*priv);
1676#if QT_DEPRECATED_SINCE(6
, 8
)
1678
1679
1680
1681
1682
1683
1684QRegularExpressionMatchIterator QRegularExpression::globalMatch(QStringView subjectView,
1686 MatchType matchType,
1687 MatchOptions matchOptions)
const
1689 return globalMatchView(subjectView, offset, matchType, matchOptions);
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711QRegularExpressionMatchIterator QRegularExpression::globalMatchView(QStringView subjectView,
1713 MatchType matchType,
1714 MatchOptions matchOptions)
const
1716 QRegularExpressionMatchIteratorPrivate *priv =
1717 new QRegularExpressionMatchIteratorPrivate(*
this,
1720 matchView(subjectView, offset, matchType, matchOptions));
1722 return QRegularExpressionMatchIterator(*priv);
1726
1727
1728
1729
1730
1731
1732
1733void QRegularExpression::optimize()
const
1735 d.data()->compilePattern();
1739
1740
1741
1742
1743
1744
1745
1746
1748 const QRegularExpression &rhs)
noexcept
1750 return (lhs.d == rhs.d) ||
1751 (lhs.d->pattern == rhs.d->pattern && lhs.d->patternOptions == rhs.d->patternOptions);
1754
1755
1756
1757
1758
1759
1760
1761
1762
1765
1766
1767
1768
1769
1770
1771
1774
1775
1776
1777
1778
1779
1780size_t qHash(
const QRegularExpression &key, size_t seed)
noexcept
1782 return qHashMulti(seed, key.d->pattern, key.d->patternOptions);
1786
1787
1788
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810QString QRegularExpression::escape(QStringView str)
1813 const qsizetype count = str.size();
1814 result.reserve(count * 2);
1818 for (qsizetype i = 0; i < count; ++i) {
1819 const QChar current = str.at(i);
1821 if (current == QChar::Null) {
1825 result.append(u'\\');
1826 result.append(u'0');
1827 }
else if ((current < u'a' || current > u'z') &&
1828 (current < u'A' || current > u'Z') &&
1829 (current < u'0' || current > u'9') &&
1831 result.append(u'\\');
1832 result.append(current);
1833 if (current.isHighSurrogate() && i < (count - 1))
1834 result.append(str.at(++i));
1836 result.append(current);
1845
1846
1847
1848
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
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
1932QString QRegularExpression::wildcardToRegularExpression(QStringView pattern, WildcardConversionOptions options)
1934 const qsizetype wclen = pattern.size();
1936 rx.reserve(wclen + wclen / 16);
1938 const QChar *wc = pattern.data();
1940 struct GlobSettings {
1941 char16_t nativePathSeparator;
1942 QStringView starEscape;
1943 QStringView questionMarkEscape;
1946 const GlobSettings settings = [options]() {
1947 if (options.testFlag(NonPathWildcardConversion)) {
1948 return GlobSettings{ u'\0', u".*", u"." };
1951 return GlobSettings{ u'\\', u"[^/\\\\]*", u"[^/\\\\]" };
1953 return GlobSettings{ u'/', u"[^/]*", u"[^/]" };
1963 const QChar c = wc[i++];
1964 switch (c.unicode()) {
1966 rx += settings.starEscape;
1968 while (i < wclen && wc[i] == u'*')
1972 rx += settings.questionMarkEscape;
1980 if (options.testFlag(NonPathWildcardConversion))
1986 if (options.testFlag(NonPathWildcardConversion))
2008 if (wc[i] == u'!') {
2013 if (i < wclen && wc[i] == u']')
2016 while (i < wclen && wc[i] != u']') {
2017 if (!options.testFlag(NonPathWildcardConversion)) {
2021 if (wc[i] == u'/' || wc[i] == settings.nativePathSeparator)
2039 if (!(options & UnanchoredWildcardConversion))
2040 rx = anchoredPattern(rx);
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058QRegularExpression QRegularExpression::fromWildcard(QStringView pattern, Qt::CaseSensitivity cs,
2059 WildcardConversionOptions options)
2061 auto reOptions = cs == Qt::CaseSensitive ? QRegularExpression::NoPatternOption :
2062 QRegularExpression::CaseInsensitiveOption;
2063 return QRegularExpression(wildcardToRegularExpression(pattern, options), reOptions);
2067
2068
2069
2070
2073
2074
2075
2076
2077
2078QString QRegularExpression::anchoredPattern(QStringView expression)
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097QRegularExpressionMatch::QRegularExpressionMatch()
2098 : d(
new QRegularExpressionMatchPrivate(QRegularExpression(),
2101 QRegularExpression::NoMatch,
2102 QRegularExpression::NoMatchOption))
2108
2109
2110QRegularExpressionMatch::~QRegularExpressionMatch()
2114QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QRegularExpressionMatchPrivate)
2117
2118
2119
2120
2121QRegularExpressionMatch::QRegularExpressionMatch(
const QRegularExpressionMatch &match)
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2141
2142
2143
2144QRegularExpressionMatch &QRegularExpressionMatch::operator=(
const QRegularExpressionMatch &match)
2151
2152
2153
2154
2155
2156
2157
2158
2159
2162
2163
2164
2167
2168
2169QRegularExpressionMatch::QRegularExpressionMatch(QRegularExpressionMatchPrivate &dd)
2175
2176
2177
2178
2179
2180QRegularExpression QRegularExpressionMatch::regularExpression()
const
2182 return d->regularExpression;
2187
2188
2189
2190
2191
2192
2193QRegularExpression::MatchType QRegularExpressionMatch::matchType()
const
2195 return d->matchType;
2199
2200
2201
2202
2203
2204
2205QRegularExpression::MatchOptions QRegularExpressionMatch::matchOptions()
const
2207 return d->matchOptions;
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224int QRegularExpressionMatch::lastCapturedIndex()
const
2226 return d->capturedCount - 1;
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252bool QRegularExpressionMatch::hasCaptured(QAnyStringView name)
const
2254 const int nth = d->regularExpression.d->captureIndexForName(name);
2255 return hasCaptured(nth);
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280bool QRegularExpressionMatch::hasCaptured(
int nth)
const
2282 if (nth < 0 || nth > lastCapturedIndex())
2285 return d->capturedOffsets.at(nth * 2) != -1;
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300QString QRegularExpressionMatch::captured(
int nth)
const
2302 return capturedView(nth).toString();
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319QStringView QRegularExpressionMatch::capturedView(
int nth)
const
2321 if (!hasCaptured(nth))
2322 return QStringView();
2324 qsizetype start = capturedStart(nth);
2327 return QStringView();
2329 return d->subject.mid(start, capturedLength(nth));
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346QString QRegularExpressionMatch::captured(QAnyStringView name)
const
2348 if (name.isEmpty()) {
2349 qWarning(
"QRegularExpressionMatch::captured: empty capturing group name passed");
2353 return capturedView(name).toString();
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371QStringView QRegularExpressionMatch::capturedView(QAnyStringView name)
const
2373 if (name.isEmpty()) {
2374 qWarning(
"QRegularExpressionMatch::capturedView: empty capturing group name passed");
2375 return QStringView();
2377 int nth = d->regularExpression.d->captureIndexForName(name);
2379 return QStringView();
2380 return capturedView(nth);
2384
2385
2386
2387
2388
2389QStringList QRegularExpressionMatch::capturedTexts()
const
2392 texts.reserve(d->capturedCount);
2393 for (
int i = 0; i < d->capturedCount; ++i)
2394 texts << captured(i);
2399
2400
2401
2402
2403
2404
2405
2406qsizetype QRegularExpressionMatch::capturedStart(
int nth)
const
2408 if (!hasCaptured(nth))
2411 return d->capturedOffsets.at(nth * 2);
2415
2416
2417
2418
2419
2420
2421
2422qsizetype QRegularExpressionMatch::capturedLength(
int nth)
const
2425 return capturedEnd(nth) - capturedStart(nth);
2429
2430
2431
2432
2433
2434
2435qsizetype QRegularExpressionMatch::capturedEnd(
int nth)
const
2437 if (!hasCaptured(nth))
2440 return d->capturedOffsets.at(nth * 2 + 1);
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456qsizetype QRegularExpressionMatch::capturedStart(QAnyStringView name)
const
2458 if (name.isEmpty()) {
2459 qWarning(
"QRegularExpressionMatch::capturedStart: empty capturing group name passed");
2462 int nth = d->regularExpression.d->captureIndexForName(name);
2465 return capturedStart(nth);
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482qsizetype QRegularExpressionMatch::capturedLength(QAnyStringView name)
const
2484 if (name.isEmpty()) {
2485 qWarning(
"QRegularExpressionMatch::capturedLength: empty capturing group name passed");
2488 int nth = d->regularExpression.d->captureIndexForName(name);
2491 return capturedLength(nth);
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507qsizetype QRegularExpressionMatch::capturedEnd(QAnyStringView name)
const
2509 if (name.isEmpty()) {
2510 qWarning(
"QRegularExpressionMatch::capturedEnd: empty capturing group name passed");
2513 int nth = d->regularExpression.d->captureIndexForName(name);
2516 return capturedEnd(nth);
2520
2521
2522
2523
2524
2525bool QRegularExpressionMatch::hasMatch()
const
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540bool QRegularExpressionMatch::hasPartialMatch()
const
2542 return d->hasPartialMatch;
2546
2547
2548
2549
2550
2551
2552bool QRegularExpressionMatch::isValid()
const
2558
2559
2560QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(QRegularExpressionMatchIteratorPrivate &dd)
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577QRegularExpressionMatchIterator::QRegularExpressionMatchIterator()
2578 : d(
new QRegularExpressionMatchIteratorPrivate(QRegularExpression(),
2579 QRegularExpression::NoMatch,
2580 QRegularExpression::NoMatchOption,
2581 QRegularExpressionMatch()))
2586
2587
2588QRegularExpressionMatchIterator::~QRegularExpressionMatchIterator()
2592QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QRegularExpressionMatchIteratorPrivate)
2595
2596
2597
2598
2599
2600QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(
const QRegularExpressionMatchIterator &iterator)
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2620
2621
2622
2623QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(
const QRegularExpressionMatchIterator &iterator)
2630
2631
2632
2633
2634
2635
2636
2637
2638
2641
2642
2643
2646
2647
2648
2649
2650
2651
2652
2653bool QRegularExpressionMatchIterator::isValid()
const
2655 return d->next.isValid();
2659
2660
2661
2662
2663
2664bool QRegularExpressionMatchIterator::hasNext()
const
2666 return d->hasNext();
2670
2671
2672
2673
2674
2675QRegularExpressionMatch QRegularExpressionMatchIterator::peekNext()
const
2678 qWarning(
"QRegularExpressionMatchIterator::peekNext() called on an iterator already at end");
2684
2685
2686
2687
2688
2689QRegularExpressionMatch QRegularExpressionMatchIterator::next()
2692 qWarning(
"QRegularExpressionMatchIterator::next() called on an iterator already at end");
2693 return d.constData()->next;
2697 return std::exchange(d->next, d->next.d.constData()->nextMatch());
2701
2702
2703
2704
2705
2706QRegularExpression QRegularExpressionMatchIterator::regularExpression()
const
2708 return d->regularExpression;
2712
2713
2714
2715
2716
2717
2718QRegularExpression::MatchType QRegularExpressionMatchIterator::matchType()
const
2720 return d->matchType;
2724
2725
2726
2727
2728
2729
2730QRegularExpression::MatchOptions QRegularExpressionMatchIterator::matchOptions()
const
2732 return d->matchOptions;
2736
2737
2744
2745
2746
2748#ifndef QT_NO_DATASTREAM
2750
2751
2752
2753
2754
2755
2758 out << re.pattern() << quint32(re.patternOptions().toInt());
2763
2764
2765
2766
2767
2768
2772 quint32 patternOptions;
2773 in >> pattern >> patternOptions;
2774 re.setPattern(pattern);
2775 re.setPatternOptions(QRegularExpression::PatternOptions::fromInt(patternOptions));
2780#ifndef QT_NO_DEBUG_STREAM
2782
2783
2784
2785
2786
2787
2788
2791 QDebugStateSaver saver(debug);
2792 debug.nospace() <<
"QRegularExpression(" << re.pattern() <<
", " << re.patternOptions() <<
')';
2797
2798
2799
2800
2801
2802
2803
2806 QDebugStateSaver saver(debug);
2809 if (patternOptions == QRegularExpression::NoPatternOption) {
2810 flags =
"NoPatternOption";
2813 if (patternOptions & QRegularExpression::CaseInsensitiveOption)
2814 flags.append(
"CaseInsensitiveOption|");
2815 if (patternOptions & QRegularExpression::DotMatchesEverythingOption)
2816 flags.append(
"DotMatchesEverythingOption|");
2817 if (patternOptions & QRegularExpression::MultilineOption)
2818 flags.append(
"MultilineOption|");
2819 if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption)
2820 flags.append(
"ExtendedPatternSyntaxOption|");
2821 if (patternOptions & QRegularExpression::InvertedGreedinessOption)
2822 flags.append(
"InvertedGreedinessOption|");
2823 if (patternOptions & QRegularExpression::DontCaptureOption)
2824 flags.append(
"DontCaptureOption|");
2825 if (patternOptions & QRegularExpression::UseUnicodePropertiesOption)
2826 flags.append(
"UseUnicodePropertiesOption|");
2830 debug.nospace() <<
"QRegularExpression::PatternOptions(" << flags <<
')';
2835
2836
2837
2838
2839
2840
2841
2844 QDebugStateSaver saver(debug);
2845 debug.nospace() <<
"QRegularExpressionMatch(";
2847 if (!match.isValid()) {
2848 debug <<
"Invalid)";
2854 if (match.hasMatch()) {
2855 debug <<
", has match: ";
2856 for (
int i = 0; i <= match.lastCapturedIndex(); ++i) {
2858 <<
":(" << match.capturedStart(i) <<
", " << match.capturedEnd(i)
2859 <<
", " << match.captured(i) <<
')';
2860 if (i < match.lastCapturedIndex())
2863 }
else if (match.hasPartialMatch()) {
2864 debug <<
", has partial match: ("
2865 << match.capturedStart(0) <<
", "
2866 << match.capturedEnd(0) <<
", "
2867 << match.captured(0) <<
')';
2869 debug <<
", no match";
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2918static const char *pcreCompileErrorCodes[] =
2920 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no error"),
2921 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\ at end of pattern"),
2922 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c at end of pattern"),
2923 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized character follows \\"),
2924 QT_TRANSLATE_NOOP(
"QRegularExpression",
"numbers out of order in {} quantifier"),
2925 QT_TRANSLATE_NOOP(
"QRegularExpression",
"number too big in {} quantifier"),
2926 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing terminating ] for character class"),
2927 QT_TRANSLATE_NOOP(
"QRegularExpression",
"escape sequence is invalid in character class"),
2928 QT_TRANSLATE_NOOP(
"QRegularExpression",
"range out of order in character class"),
2929 QT_TRANSLATE_NOOP(
"QRegularExpression",
"quantifier does not follow a repeatable item"),
2930 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unexpected repeat"),
2931 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized character after (? or (?-"),
2932 QT_TRANSLATE_NOOP(
"QRegularExpression",
"POSIX named classes are supported only within a class"),
2933 QT_TRANSLATE_NOOP(
"QRegularExpression",
"POSIX collating elements are not supported"),
2934 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing closing parenthesis"),
2935 QT_TRANSLATE_NOOP(
"QRegularExpression",
"reference to non-existent subpattern"),
2936 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern passed as NULL"),
2937 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognised compile-time option bit(s)"),
2938 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing ) after (?# comment"),
2939 QT_TRANSLATE_NOOP(
"QRegularExpression",
"parentheses are too deeply nested"),
2940 QT_TRANSLATE_NOOP(
"QRegularExpression",
"regular expression is too large"),
2941 QT_TRANSLATE_NOOP(
"QRegularExpression",
"failed to allocate heap memory"),
2942 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unmatched closing parenthesis"),
2943 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: code overflow"),
2944 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing closing parenthesis for condition"),
2945 QT_TRANSLATE_NOOP(
"QRegularExpression",
"lookbehind assertion is not fixed length"),
2946 QT_TRANSLATE_NOOP(
"QRegularExpression",
"a relative value of zero is not allowed"),
2947 QT_TRANSLATE_NOOP(
"QRegularExpression",
"conditional subpattern contains more than two branches"),
2948 QT_TRANSLATE_NOOP(
"QRegularExpression",
"assertion expected after (?( or (?(?C)"),
2949 QT_TRANSLATE_NOOP(
"QRegularExpression",
"digit expected after (?+ or (?-"),
2950 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unknown POSIX class name"),
2951 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error in pcre2_study(): should not occur"),
2952 QT_TRANSLATE_NOOP(
"QRegularExpression",
"this version of PCRE2 does not have Unicode support"),
2953 QT_TRANSLATE_NOOP(
"QRegularExpression",
"parentheses are too deeply nested (stack check)"),
2954 QT_TRANSLATE_NOOP(
"QRegularExpression",
"character code point value in \\x{} or \\o{} is too large"),
2955 QT_TRANSLATE_NOOP(
"QRegularExpression",
"lookbehind is too complicated"),
2956 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\C is not allowed in a lookbehind assertion in UTF-" "16" " mode"),
2957 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2 does not support \\F, \\L, \\l, \\N{name}, \\U, or \\u"),
2958 QT_TRANSLATE_NOOP(
"QRegularExpression",
"number after (?C is greater than 255"),
2959 QT_TRANSLATE_NOOP(
"QRegularExpression",
"closing parenthesis for (?C expected"),
2960 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid escape sequence in (*VERB) name"),
2961 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized character after (?P"),
2962 QT_TRANSLATE_NOOP(
"QRegularExpression",
"syntax error in subpattern name (missing terminator?)"),
2963 QT_TRANSLATE_NOOP(
"QRegularExpression",
"two named subpatterns have the same name (PCRE2_DUPNAMES not set)"),
2964 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name must start with a non-digit"),
2965 QT_TRANSLATE_NOOP(
"QRegularExpression",
"this version of PCRE2 does not have support for \\P, \\p, or \\X"),
2966 QT_TRANSLATE_NOOP(
"QRegularExpression",
"malformed \\P or \\p sequence"),
2967 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unknown property name after \\P or \\p"),
2968 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name is too long (maximum " "32" " code units)"),
2969 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many named subpatterns (maximum " "10000" ")"),
2970 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid range in character class"),
2971 QT_TRANSLATE_NOOP(
"QRegularExpression",
"octal value is greater than \\377 in 8-bit non-UTF-8 mode"),
2972 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: overran compiling workspace"),
2973 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: previously-checked referenced subpattern not found"),
2974 QT_TRANSLATE_NOOP(
"QRegularExpression",
"DEFINE subpattern contains more than one branch"),
2975 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing opening brace after \\o"),
2976 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown newline setting"),
2977 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number"),
2978 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(?R (recursive pattern call) must be followed by a closing parenthesis"),
2979 QT_TRANSLATE_NOOP(
"QRegularExpression",
"obsolete error (should not occur)"),
2980 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(*VERB) not recognized or malformed"),
2981 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern number is too big"),
2982 QT_TRANSLATE_NOOP(
"QRegularExpression",
"subpattern name expected"),
2983 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: parsed pattern overflow"),
2984 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-octal character in \\o{} (closing brace missing?)"),
2985 QT_TRANSLATE_NOOP(
"QRegularExpression",
"different names for subpatterns of the same number are not allowed"),
2986 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(*MARK) must have an argument"),
2987 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-hex character in \\x{} (closing brace missing?)"),
2988 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c must be followed by a printable ASCII character"),
2989 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\c must be followed by a letter or one of [\\]^_?"),
2990 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\k is not followed by a braced, angle-bracketed, or quoted name"),
2991 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown meta code in check_lookbehinds()"),
2992 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\N is not supported in a class"),
2993 QT_TRANSLATE_NOOP(
"QRegularExpression",
"callout string is too long"),
2994 QT_TRANSLATE_NOOP(
"QRegularExpression",
"disallowed Unicode code point (>= 0xd800 && <= 0xdfff)"),
2995 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using UTF is disabled by the application"),
2996 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using UCP is disabled by the application"),
2997 QT_TRANSLATE_NOOP(
"QRegularExpression",
"name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)"),
2998 QT_TRANSLATE_NOOP(
"QRegularExpression",
"character code point value in \\u.... sequence is too large"),
2999 QT_TRANSLATE_NOOP(
"QRegularExpression",
"digits missing in \\x{} or \\o{} or \\N{U+}"),
3000 QT_TRANSLATE_NOOP(
"QRegularExpression",
"syntax error or number too big in (?(VERSION condition"),
3001 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown opcode in auto_possessify()"),
3002 QT_TRANSLATE_NOOP(
"QRegularExpression",
"missing terminating delimiter for callout with string argument"),
3003 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unrecognized string delimiter follows (?C"),
3004 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using \\C is disabled by the application"),
3005 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(?| and/or (?J: or (?x: parentheses are too deeply nested"),
3006 QT_TRANSLATE_NOOP(
"QRegularExpression",
"using \\C is disabled in this PCRE2 library"),
3007 QT_TRANSLATE_NOOP(
"QRegularExpression",
"regular expression is too complicated"),
3008 QT_TRANSLATE_NOOP(
"QRegularExpression",
"lookbehind assertion is too long"),
3009 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern string is longer than the limit set by the application"),
3010 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: unknown code in parsed pattern"),
3011 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error: bad code value in parsed_skip()"),
3012 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES is not allowed in UTF-16 mode"),
3013 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid option bits with PCRE2_LITERAL"),
3014 QT_TRANSLATE_NOOP(
"QRegularExpression",
"\\N{U+dddd} is supported only in Unicode (UTF) mode"),
3015 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid hyphen in option setting"),
3016 QT_TRANSLATE_NOOP(
"QRegularExpression",
"(*alpha_assertion) not recognized"),
3017 QT_TRANSLATE_NOOP(
"QRegularExpression",
"script runs require Unicode support, which this version of PCRE2 does not have"),
3018 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many capturing groups (maximum 65535)"),
3019 QT_TRANSLATE_NOOP(
"QRegularExpression",
"atomic assertion expected after (?( or (?(?C)"),
3020 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no error"),
3021 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no match"),
3022 QT_TRANSLATE_NOOP(
"QRegularExpression",
"partial match"),
3023 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 1 byte missing at end"),
3024 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 2 bytes missing at end"),
3025 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 3 bytes missing at end"),
3026 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 4 bytes missing at end"),
3027 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 5 bytes missing at end"),
3028 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 2 top bits not 0x80"),
3029 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 3 top bits not 0x80"),
3030 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 4 top bits not 0x80"),
3031 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 5 top bits not 0x80"),
3032 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: byte 6 top bits not 0x80"),
3033 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 5-byte character is not allowed (RFC 3629)"),
3034 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: 6-byte character is not allowed (RFC 3629)"),
3035 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: code points greater than 0x10ffff are not defined"),
3036 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: code points 0xd800-0xdfff are not defined"),
3037 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 2-byte sequence"),
3038 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 3-byte sequence"),
3039 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 4-byte sequence"),
3040 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 5-byte sequence"),
3041 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: overlong 6-byte sequence"),
3042 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: isolated byte with 0x80 bit set"),
3043 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-8 error: illegal byte (0xfe or 0xff)"),
3044 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: missing low surrogate at end"),
3045 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: invalid low surrogate"),
3046 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-16 error: isolated low surrogate"),
3047 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-32 error: code points 0xd800-0xdfff are not defined"),
3048 QT_TRANSLATE_NOOP(
"QRegularExpression",
"UTF-32 error: code points greater than 0x10ffff are not defined"),
3049 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad data value"),
3050 QT_TRANSLATE_NOOP(
"QRegularExpression",
"patterns do not all use the same character tables"),
3051 QT_TRANSLATE_NOOP(
"QRegularExpression",
"magic number missing"),
3052 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern compiled in wrong mode: 8/16/32-bit error"),
3053 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad offset value"),
3054 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad option value"),
3055 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid replacement string"),
3056 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad offset into UTF string"),
3057 QT_TRANSLATE_NOOP(
"QRegularExpression",
"callout error code"),
3058 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid data in workspace for DFA restart"),
3059 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too much recursion for DFA matching"),
3060 QT_TRANSLATE_NOOP(
"QRegularExpression",
"backreference condition or recursion test is not supported for DFA matching"),
3061 QT_TRANSLATE_NOOP(
"QRegularExpression",
"function is not supported for DFA matching"),
3062 QT_TRANSLATE_NOOP(
"QRegularExpression",
"pattern contains an item that is not supported for DFA matching"),
3063 QT_TRANSLATE_NOOP(
"QRegularExpression",
"workspace size exceeded in DFA matching"),
3064 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error - pattern overwritten?"),
3065 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad JIT option"),
3066 QT_TRANSLATE_NOOP(
"QRegularExpression",
"JIT stack limit reached"),
3067 QT_TRANSLATE_NOOP(
"QRegularExpression",
"match limit exceeded"),
3068 QT_TRANSLATE_NOOP(
"QRegularExpression",
"no more memory"),
3069 QT_TRANSLATE_NOOP(
"QRegularExpression",
"unknown substring"),
3070 QT_TRANSLATE_NOOP(
"QRegularExpression",
"non-unique substring name"),
3071 QT_TRANSLATE_NOOP(
"QRegularExpression",
"NULL argument passed"),
3072 QT_TRANSLATE_NOOP(
"QRegularExpression",
"nested recursion at the same subject position"),
3073 QT_TRANSLATE_NOOP(
"QRegularExpression",
"matching depth limit exceeded"),
3074 QT_TRANSLATE_NOOP(
"QRegularExpression",
"requested value is not available"),
3075 QT_TRANSLATE_NOOP(
"QRegularExpression",
"requested value is not set"),
3076 QT_TRANSLATE_NOOP(
"QRegularExpression",
"offset limit set without PCRE2_USE_OFFSET_LIMIT"),
3077 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad escape sequence in replacement string"),
3078 QT_TRANSLATE_NOOP(
"QRegularExpression",
"expected closing curly bracket in replacement string"),
3079 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad substitution in replacement string"),
3080 QT_TRANSLATE_NOOP(
"QRegularExpression",
"match with end before start or start moved backwards is not supported"),
3081 QT_TRANSLATE_NOOP(
"QRegularExpression",
"too many replacements (more than INT_MAX)"),
3082 QT_TRANSLATE_NOOP(
"QRegularExpression",
"bad serialized data"),
3083 QT_TRANSLATE_NOOP(
"QRegularExpression",
"heap limit exceeded"),
3084 QT_TRANSLATE_NOOP(
"QRegularExpression",
"invalid syntax"),
3085 QT_TRANSLATE_NOOP(
"QRegularExpression",
"internal error - duplicate substitution match"),
3086 QT_TRANSLATE_NOOP(
"QRegularExpression",
"PCRE2_MATCH_INVALID_UTF is not supported for DFA matching"),
3087 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, QIODevice::OpenMode modes)
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