Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
//
// WordBoundaries.swift
// Patterns
//
// Created by Kåre Morstøl on 28/06/2019.
//
public struct Word {
/// Detects boundaries between words.
///
/// Uses rules from https://www.unicode.org/reports/tr29/#Word_Boundary_Rules .
public struct Boundary: Pattern {
public typealias Input = String
public let description: String = "Word.Boundary()"
public init() {}
// TODO: Should use UnicodeScalars. And return bool.
@usableFromInline
func parse(_ input: Input, at index: Input.Index) -> ParsedRange? {
let success = index ..< index
guard index != input.endIndex, index != input.startIndex else { return success }
let char1After = input[index]
let char1Before = input[input.index(before: index)]
if char1Before.isNewline || char1After.isNewline { return success }
func before(_ b1: Group<UInt32>) -> Bool {
b1.contains(char1Before)
}
func after(_ a1: Group<UInt32>) -> Bool {
a1.contains(char1After)
}
if before(wSegSpace), after(wSegSpace) { return nil }
if before(aHLetter), after(aHLetter) { return nil }
let char2After = input.validIndex(index, offsetBy: +1).map { input[$0] }
func after2(_ a1: Group<UInt32>, _ a2: Group<UInt32>) -> Bool {
a1.contains(char1After) && char2After.map(a2.contains) ?? false
}
let char2Before = input.index(index, offsetBy: -2, limitedBy: input.startIndex).map { input[$0] }
func before2(_ b2: Group<UInt32>, _ b1: Group<UInt32>) -> Bool {
b1.contains(char1Before) && (char2Before.map(b2.contains) ?? false)
}
if before(aHLetter), after2(midLetter || midNumLetQ, aHLetter) { return nil }
if before2(aHLetter, midLetter || midNumLetQ), after(aHLetter) { return nil }
if before(hebrewLetter), after(singleQuote) { return nil }
if before(hebrewLetter), after2(doubleQuote, hebrewLetter) { return nil }
if before2(hebrewLetter, doubleQuote), after(hebrewLetter) { return nil }
if before(numeric), after(numeric) { return nil }
if before(aHLetter), after(numeric) { return nil }
if before(numeric), after(aHLetter) { return nil }
if before2(numeric, midNum || midNumLetQ), after(numeric) { return nil }
if before(numeric), after2(midNum || midNumLetQ, numeric) { return nil }
if before(katakana), after(katakana) { return nil }
if before(aHLetter || numeric || katakana || extendNumLet), after(extendNumLet) { return nil }
if before(extendNumLet), after(aHLetter || numeric || katakana) { return nil }
return success
}
@inlinable
public func createInstructions(_ instructions: inout ContiguousArray<Instruction<Input>>) {
instructions.append(.checkIndex { (input, index) -> Bool in
self.parse(input, at: index) != nil
})
}
}
}
extension Word {
/// Detects boundaries between words.
///
/// Uses rules from https://www.unicode.org/reports/tr29/#Word_Boundary_Rules .
@available(*, deprecated, renamed: "Boundary()")
public static let boundary = Boundary()
}
extension Group where Element == UInt32 {
init(_ c: ClosedRange<Element>...) {
// The collection is sorted. Exit as soon as possible.
self.contains = { element in
for range in c {
if element < range.lowerBound {
return false
}
if element <= range.upperBound {
return true
}
}
return false
}
}
func contains(_ c: Character) -> Bool {
contains(c.unicodeScalars.first!.value)
}
}
private let singleQuote = Group(39 ... 39)
private let midNumLet = Group(46 ... 46, 8216 ... 8217, 8228 ... 8228, 65106 ... 65106, 65287 ... 65287, 65294 ... 65294)
private let midLetter = Group(58 ... 58, 183 ... 183, 903 ... 903, 1524 ... 1524, 8231 ... 8231, 65043 ... 65043, 65109 ... 65109, 65306 ... 65306)
private let format = Group(173 ... 173, 1536 ... 1541, 1564 ... 1564, 1757 ... 1757, 1807 ... 1807, 2274 ... 2274, 6158 ... 6158, 8206 ... 8207, 8234 ... 8238, 8288 ... 8292, 8294 ... 8303, 65279 ... 65279, 65529 ... 65531, 69821 ... 69821, 69837 ... 69837, 78896 ... 78904, 113_824 ... 113_827, 119_155 ... 119_162, 917_505 ... 917_505)
private let numeric = Group(48 ... 57, 1632 ... 1641, 1643 ... 1643, 1776 ... 1785, 1984 ... 1993, 2406 ... 2415, 2534 ... 2543, 2662 ... 2671, 2790 ... 2799, 2918 ... 2927, 3046 ... 3055, 3174 ... 3183, 3302 ... 3311, 3430 ... 3439, 3558 ... 3567, 3664 ... 3673, 3792 ... 3801, 3872 ... 3881, 4160 ... 4169, 4240 ... 4249, 6112 ... 6121, 6160 ... 6169, 6470 ... 6479, 6608 ... 6617, 6784 ... 6793, 6800 ... 6809, 6992 ... 7001, 7088 ... 7097, 7232 ... 7241, 7248 ... 7257, 42528 ... 42537, 43216 ... 43225, 43264 ... 43273, 43472 ... 43481, 43504 ... 43513, 43600 ... 43609, 44016 ... 44025, 65296 ... 65305, 66720 ... 66729, 68912 ... 68921, 69734 ... 69743, 69872 ... 69881, 69942 ... 69951, 70096 ... 70105, 70384 ... 70393, 70736 ... 70745, 70864 ... 70873, 71248 ... 71257, 71360 ... 71369, 71472 ... 71481, 71904 ... 71913, 72784 ... 72793, 73040 ... 73049, 73120 ... 73129, 92768 ... 92777, 93008 ... 93017, 120_782 ... 120_831, 123_200 ... 123_209, 123_632 ... 123_641, 125_264 ... 125_273)
private let katakana = Group(12337 ... 12341, 12443 ... 12444, 12448 ... 12538, 12540 ... 12543, 12784 ... 12799, 13008 ... 13054, 13056 ... 13143, 65382 ... 65437, 110_592 ... 110_592, 110_948 ... 110_951)
private let wSegSpace = Group(32 ... 32, 5760 ... 5760, 8192 ... 8198, 8200 ... 8202, 8287 ... 8287, 12288 ... 12288)
private let hebrewLetter = Group(1488 ... 1514, 1519 ... 1522, 64285 ... 64285, 64287 ... 64296, 64298 ... 64310, 64312 ... 64316, 64318 ... 64318, 64320 ... 64321, 64323 ... 64324, 64326 ... 64335)
private let CR = Group(13 ... 13)
private let doubleQuote = Group(34 ... 34)
private let midNum = Group(44 ... 44, 59 ... 59, 894 ... 894, 1417 ... 1417, 1548 ... 1549, 1644 ... 1644, 2040 ... 2040, 8260 ... 8260, 65040 ... 65040, 65044 ... 65044, 65104 ... 65104, 65108 ... 65108, 65292 ... 65292, 65307 ... 65307)
private let LF = Group(10 ... 10)
private let extend = Group(768 ... 879, 1155 ... 1161, 1425 ... 1469, 1471 ... 1471, 1473 ... 1474, 1476 ... 1477, 1479 ... 1479, 1552 ... 1562, 1611 ... 1631, 1648 ... 1648, 1750 ... 1756, 1759 ... 1764, 1767 ... 1768, 1770 ... 1773, 1809 ... 1809, 1840 ... 1866, 1958 ... 1968, 2027 ... 2035, 2045 ... 2045, 2070 ... 2073, 2075 ... 2083, 2085 ... 2087, 2089 ... 2093, 2137 ... 2139, 2259 ... 2273, 2275 ... 2307, 2362 ... 2364, 2366 ... 2383, 2385 ... 2391, 2402 ... 2403, 2433 ... 2435, 2492 ... 2492, 2494 ... 2500, 2503 ... 2504, 2507 ... 2509, 2519 ... 2519, 2530 ... 2531, 2558 ... 2558, 2561 ... 2563, 2620 ... 2620, 2622 ... 2626, 2631 ... 2632, 2635 ... 2637, 2641 ... 2641, 2672 ... 2673, 2677 ... 2677, 2689 ... 2691, 2748 ... 2748, 2750 ... 2757, 2759 ... 2761, 2763 ... 2765, 2786 ... 2787, 2810 ... 2815, 2817 ... 2819, 2876 ... 2876, 2878 ... 2884, 2887 ... 2888, 2891 ... 2893, 2902 ... 2903, 2914 ... 2915, 2946 ... 2946, 3006 ... 3010, 3014 ... 3016, 3018 ... 3021, 3031 ... 3031, 3072 ... 3076, 3134 ... 3140, 3142 ... 3144, 3146 ... 3149, 3157 ... 3158, 3170 ... 3171, 3201 ... 3203, 3260 ... 3260, 3262 ... 3268, 3270 ... 3272, 3274 ... 3277, 3285 ... 3286, 3298 ... 3299, 3328 ... 3331, 3387 ... 3388, 3390 ... 3396, 3398 ... 3400, 3402 ... 3405, 3415 ... 3415, 3426 ... 3427, 3458 ... 3459, 3530 ... 3530, 3535 ... 3540, 3542 ... 3542, 3544 ... 3551, 3570 ... 3571, 3633 ... 3633, 3636 ... 3642, 3655 ... 3662, 3761 ... 3761, 3764 ... 3772, 3784 ... 3789, 3864 ... 3865, 3893 ... 3893, 3895 ... 3895, 3897 ... 3897, 3902 ... 3903, 3953 ... 3972, 3974 ... 3975, 3981 ... 3991, 3993 ... 4028, 4038 ... 4038, 4139 ... 4158, 4182 ... 4185, 4190 ... 4192, 4194 ... 4196, 4199 ... 4205, 4209 ... 4212, 4226 ... 4237, 4239 ... 4239, 4250 ... 4253, 4957 ... 4959, 5906 ... 5908, 5938 ... 5940, 5970 ... 5971, 6002 ... 6003, 6068 ... 6099, 6109 ... 6109, 6155 ... 6157, 6277 ... 6278, 6313 ... 6313, 6432 ... 6443, 6448 ... 6459, 6679 ... 6683, 6741 ... 6750, 6752 ... 6780, 6783 ... 6783, 6832 ... 6846, 6912 ... 6916, 6964 ... 6980, 7019 ... 7027, 7040 ... 7042, 7073 ... 7085, 7142 ... 7155, 7204 ... 7223, 7376 ... 7378, 7380 ... 7400, 7405 ... 7405, 7412 ... 7412, 7415 ... 7417, 7616 ... 7673, 7675 ... 7679, 8204 ... 8204, 8400 ... 8432, 11503 ... 11505, 11647 ... 11647, 11744 ... 11775, 12330 ... 12335, 12441 ... 12442, 42607 ... 42610, 42612 ... 42621, 42654 ... 42655, 42736 ... 42737, 43010 ... 43010, 43014 ... 43014, 43019 ... 43019, 43043 ... 43047, 43136 ... 43137, 43188 ... 43205, 43232 ... 43249, 43263 ... 43263, 43302 ... 43309, 43335 ... 43347, 43392 ... 43395, 43443 ... 43456, 43493 ... 43493, 43561 ... 43574, 43587 ... 43587, 43596 ... 43597, 43643 ... 43645, 43696 ... 43696, 43698 ... 43700, 43703 ... 43704, 43710 ... 43711, 43713 ... 43713, 43755 ... 43759, 43765 ... 43766, 44003 ... 44010, 44012 ... 44013, 64286 ... 64286, 65024 ... 65039, 65056 ... 65071, 65438 ... 65439, 66045 ... 66045, 66272 ... 66272, 66422 ... 66426, 68097 ... 68099, 68101 ... 68102, 68108 ... 68111, 68152 ... 68154, 68159 ... 68159, 68325 ... 68326, 68900 ... 68903, 69446 ... 69456, 69632 ... 69634, 69688 ... 69702, 69759 ... 69762, 69808 ... 69818, 69888 ... 69890, 69927 ... 69940, 69957 ... 69958, 70003 ... 70003, 70016 ... 70018, 70067 ... 70080, 70089 ... 70092, 70188 ... 70199, 70206 ... 70206, 70367 ... 70378, 70400 ... 70403, 70459 ... 70460, 70462 ... 70468, 70471 ... 70472, 70475 ... 70477, 70487 ... 70487, 70498 ... 70499, 70502 ... 70508, 70512 ... 70516, 70709 ... 70726, 70750 ... 70750, 70832 ... 70851, 71087 ... 71093, 71096 ... 71104, 71132 ... 71133, 71216 ... 71232, 71339 ... 71351, 71453 ... 71467, 71724 ... 71738, 72145 ... 72151, 72154 ... 72160, 72164 ... 72164, 72193 ... 72202, 72243 ... 72249, 72251 ... 72254, 72263 ... 72263, 72273 ... 72283, 72330 ... 72345, 72751 ... 72758, 72760 ... 72767, 72850 ... 72871, 72873 ... 72886, 73009 ... 73014, 73018 ... 73018, 73020 ... 73021, 73023 ... 73029, 73031 ... 73031, 73098 ... 73102, 73104 ... 73105, 73107 ... 73111, 73459 ... 73462, 92912 ... 92916, 92976 ... 92982, 94031 ... 94031, 94033 ... 94087, 94095 ... 94098, 113_821 ... 113_822, 119_141 ... 119_145, 119_149 ... 119_154, 119_163 ... 119_170, 119_173 ... 119_179, 119_210 ... 119_213, 119_362 ... 119_364, 121_344 ... 121_398, 121_403 ... 121_452, 121_461 ... 121_461, 121_476 ... 121_476, 121_499 ... 121_503, 121_505 ... 121_519, 122_880 ... 122_886, 122_888 ... 122_904, 122_907 ... 122_913, 122_915 ... 122_916, 122_918 ... 122_922, 123_184 ... 123_190, 123_628 ... 123_631, 125_136 ... 125_142, 125_252 ... 125_258, 127_995 ... 127_999, 917_536 ... 917_631, 917_760 ... 917_999)
private let extendNumLet = Group(95 ... 95, 8239 ... 8239, 8255 ... 8256, 8276 ... 8276, 65075 ... 65076, 65101 ... 65103, 65343 ... 65343)
private let ZWJ = Group(8205 ... 8205)
private let aLetter = Group<UInt32>(65 ... 90, 97 ... 122, 170 ... 170, 181 ... 181, 186 ... 186, 192 ... 214, 216 ... 246, 248 ... 727, 734 ... 740, 748 ... 767, 880 ... 884, 886 ... 887, 890 ... 893, 895 ... 895, 902 ... 902, 904 ... 906, 908 ... 908, 910 ... 929, 931 ... 1013, 1015 ... 1153, 1162 ... 1327, 1329 ... 1366, 1369 ... 1369, 1371 ... 1372, 1374 ... 1374, 1376 ... 1416, 1523 ... 1523, 1568 ... 1610, 1646 ... 1647, 1649 ... 1747, 1749 ... 1749, 1765 ... 1766, 1774 ... 1775, 1786 ... 1788, 1791 ... 1791, 1808 ... 1808, 1810 ... 1839, 1869 ... 1957, 1969 ... 1969, 1994 ... 2026, 2036 ... 2037, 2042 ... 2042, 2048 ... 2069, 2074 ... 2074, 2084 ... 2084, 2088 ... 2088, 2112 ... 2136, 2144 ... 2154, 2208 ... 2228, 2230 ... 2237, 2308 ... 2361, 2365 ... 2365, 2384 ... 2384, 2392 ... 2401, 2417 ... 2432, 2437 ... 2444, 2447 ... 2448, 2451 ... 2472, 2474 ... 2480, 2482 ... 2482, 2486 ... 2489, 2493 ... 2493, 2510 ... 2510, 2524 ... 2525, 2527 ... 2529, 2544 ... 2545, 2556 ... 2556, 2565 ... 2570, 2575 ... 2576, 2579 ... 2600, 2602 ... 2608, 2610 ... 2611, 2613 ... 2614, 2616 ... 2617, 2649 ... 2652, 2654 ... 2654, 2674 ... 2676, 2693 ... 2701, 2703 ... 2705, 2707 ... 2728, 2730 ... 2736, 2738 ... 2739, 2741 ... 2745, 2749 ... 2749, 2768 ... 2768, 2784 ... 2785, 2809 ... 2809, 2821 ... 2828, 2831 ... 2832, 2835 ... 2856, 2858 ... 2864, 2866 ... 2867, 2869 ... 2873, 2877 ... 2877, 2908 ... 2909, 2911 ... 2913, 2929 ... 2929, 2947 ... 2947, 2949 ... 2954, 2958 ... 2960, 2962 ... 2965, 2969 ... 2970, 2972 ... 2972, 2974 ... 2975, 2979 ... 2980, 2984 ... 2986, 2990 ... 3001, 3024 ... 3024, 3077 ... 3084, 3086 ... 3088, 3090 ... 3112, 3114 ... 3129, 3133 ... 3133, 3160 ... 3162, 3168 ... 3169, 3200 ... 3200, 3205 ... 3212, 3214 ... 3216, 3218 ... 3240, 3242 ... 3251, 3253 ... 3257, 3261 ... 3261, 3294 ... 3294, 3296 ... 3297, 3313 ... 3314, 3333 ... 3340, 3342 ... 3344, 3346 ... 3386, 3389 ... 3389, 3406 ... 3406, 3412 ... 3414, 3423 ... 3425, 3450 ... 3455, 3461 ... 3478, 3482 ... 3505, 3507 ... 3515, 3517 ... 3517, 3520 ... 3526, 3840 ... 3840, 3904 ... 3911, 3913 ... 3948, 3976 ... 3980, 4256 ... 4293, 4295 ... 4295, 4301 ... 4301, 4304 ... 4346, 4348 ... 4680, 4682 ... 4685, 4688 ... 4694, 4696 ... 4696, 4698 ... 4701, 4704 ... 4744, 4746 ... 4749, 4752 ... 4784, 4786 ... 4789, 4792 ... 4798, 4800 ... 4800, 4802 ... 4805, 4808 ... 4822, 4824 ... 4880, 4882 ... 4885, 4888 ... 4954, 4992 ... 5007, 5024 ... 5109, 5112 ... 5117, 5121 ... 5740, 5743 ... 5759, 5761 ... 5786, 5792 ... 5866, 5870 ... 5880, 5888 ... 5900, 5902 ... 5905, 5920 ... 5937, 5952 ... 5969, 5984 ... 5996, 5998 ... 6000, 6176 ... 6264, 6272 ... 6276, 6279 ... 6312, 6314 ... 6314, 6320 ... 6389, 6400 ... 6430, 6656 ... 6678, 6917 ... 6963, 6981 ... 6987, 7043 ... 7072, 7086 ... 7087, 7098 ... 7141, 7168 ... 7203, 7245 ... 7247, 7258 ... 7293, 7296 ... 7304, 7312 ... 7354, 7357 ... 7359, 7401 ... 7404, 7406 ... 7411, 7413 ... 7414, 7418 ... 7418, 7424 ... 7615, 7680 ... 7957, 7960 ... 7965, 7968 ... 8005, 8008 ... 8013, 8016 ... 8023, 8025 ... 8025, 8027 ... 8027, 8029 ... 8029, 8031 ... 8061, 8064 ... 8116, 8118 ... 8124, 8126 ... 8126, 8130 ... 8132, 8134 ... 8140, 8144 ... 8147, 8150 ... 8155, 8160 ... 8172, 8178 ... 8180, 8182 ... 8188, 8305 ... 8305, 8319 ... 8319, 8336 ... 8348, 8450 ... 8450, 8455 ... 8455, 8458 ... 8467, 8469 ... 8469, 8473 ... 8477, 8484 ... 8484, 8486 ... 8486, 8488 ... 8488, 8490 ... 8493, 8495 ... 8505, 8508 ... 8511, 8517 ... 8521, 8526 ... 8526, 8544 ... 8584, 9398 ... 9449, 11264 ... 11310, 11312 ... 11358, 11360 ... 11492, 11499 ... 11502, 11506 ... 11507, 11520 ... 11557, 11559 ... 11559, 11565 ... 11565, 11568 ... 11623, 11631 ... 11631, 11648 ... 11670, 11680 ... 11686, 11688 ... 11694, 11696 ... 11702, 11704 ... 11710, 11712 ... 11718, 11720 ... 11726, 11728 ... 11734, 11736 ... 11742, 11823 ... 11823, 12293 ... 12293, 12347 ... 12348, 12549 ... 12591, 12593 ... 12686, 12704 ... 12730, 40960 ... 42124, 42192 ... 42237, 42240 ... 42508, 42512 ... 42527, 42538 ... 42539, 42560 ... 42606, 42623 ... 42653, 42656 ... 42735, 42775 ... 42943, 42946 ... 42950, 42999 ... 43009, 43011 ... 43013, 43015 ... 43018, 43020 ... 43042, 43072 ... 43123, 43138 ... 43187, 43250 ... 43255, 43259 ... 43259, 43261 ... 43262, 43274 ... 43301, 43312 ... 43334, 43360 ... 43388, 43396 ... 43442, 43471 ... 43471, 43520 ... 43560, 43584 ... 43586, 43588 ... 43595, 43744 ... 43754, 43762 ... 43764, 43777 ... 43782, 43785 ... 43790, 43793 ... 43798, 43808 ... 43814, 43816 ... 43822, 43824 ... 43879, 43888 ... 44002, 44032 ... 55203, 55216 ... 55238, 55243 ... 55291, 64256 ... 64262, 64275 ... 64279, 64336 ... 64433, 64467 ... 64829, 64848 ... 64911, 64914 ... 64967, 65008 ... 65019, 65136 ... 65140, 65142 ... 65276, 65313 ... 65338, 65345 ... 65370, 65440 ... 65470, 65474 ... 65479, 65482 ... 65487, 65490 ... 65495, 65498 ... 65500, 65536 ... 65547, 65549 ... 65574, 65576 ... 65594, 65596 ... 65597, 65599 ... 65613, 65616 ... 65629, 65664 ... 65786, 65856 ... 65908, 66176 ... 66204, 66208 ... 66256, 66304 ... 66335, 66349 ... 66378, 66384 ... 66421, 66432 ... 66461, 66464 ... 66499, 66504 ... 66511, 66513 ... 66517, 66560 ... 66717, 66736 ... 66771, 66776 ... 66811, 66816 ... 66855, 66864 ... 66915, 67072 ... 67382, 67392 ... 67413, 67424 ... 67431, 67584 ... 67589, 67592 ... 67592, 67594 ... 67637, 67639 ... 67640, 67644 ... 67644, 67647 ... 67669, 67680 ... 67702, 67712 ... 67742, 67808 ... 67826, 67828 ... 67829, 67840 ... 67861, 67872 ... 67897, 67968 ... 68023, 68030 ... 68031, 68096 ... 68096, 68112 ... 68115, 68117 ... 68119, 68121 ... 68149, 68192 ... 68220, 68224 ... 68252, 68288 ... 68295, 68297 ... 68324, 68352 ... 68405, 68416 ... 68437, 68448 ... 68466, 68480 ... 68497, 68608 ... 68680, 68736 ... 68786, 68800 ... 68850, 68864 ... 68899, 69376 ... 69404, 69415 ... 69415, 69424 ... 69445, 69600 ... 69622, 69635 ... 69687, 69763 ... 69807, 69840 ... 69864, 69891 ... 69926, 69956 ... 69956, 69968 ... 70002, 70006 ... 70006, 70019 ... 70066, 70081 ... 70084, 70106 ... 70106, 70108 ... 70108, 70144 ... 70161, 70163 ... 70187, 70272 ... 70278, 70280 ... 70280, 70282 ... 70285, 70287 ... 70301, 70303 ... 70312, 70320 ... 70366, 70405 ... 70412, 70415 ... 70416, 70419 ... 70440, 70442 ... 70448, 70450 ... 70451, 70453 ... 70457, 70461 ... 70461, 70480 ... 70480, 70493 ... 70497, 70656 ... 70708, 70727 ... 70730, 70751 ... 70751, 70784 ... 70831, 70852 ... 70853, 70855 ... 70855, 71040 ... 71086, 71128 ... 71131, 71168 ... 71215, 71236 ... 71236, 71296 ... 71338, 71352 ... 71352, 71680 ... 71723, 71840 ... 71903, 71935 ... 71935, 72096 ... 72103, 72106 ... 72144, 72161 ... 72161, 72163 ... 72163, 72192 ... 72192, 72203 ... 72242, 72250 ... 72250, 72272 ... 72272, 72284 ... 72329, 72349 ... 72349, 72384 ... 72440, 72704 ... 72712, 72714 ... 72750, 72768 ... 72768, 72818 ... 72847, 72960 ... 72966, 72968 ... 72969, 72971 ... 73008, 73030 ... 73030, 73056 ... 73061, 73063 ... 73064, 73066 ... 73097, 73112 ... 73112, 73440 ... 73458, 73728 ... 74649, 74752 ... 74862, 74880 ... 75075, 77824 ... 78894, 82944 ... 83526, 92160 ... 92728, 92736 ... 92766, 92880 ... 92909, 92928 ... 92975, 92992 ... 92995, 93027 ... 93047, 93053 ... 93071, 93760 ... 93823, 93952 ... 94026, 94032 ... 94032, 94099 ... 94111, 94176 ... 94177, 94179 ... 94179, 113_664 ... 113_770, 113_776 ... 113_788, 113_792 ... 113_800, 113_808 ... 113_817, 119_808 ... 119_892, 119_894 ... 119_964, 119_966 ... 119_967, 119_970 ... 119_970, 119_973 ... 119_974, 119_977 ... 119_980, 119_982 ... 119_993, 119_995 ... 119_995, 119_997 ... 120_003, 120_005 ... 120_069, 120_071 ... 120_074, 120_077 ... 120_084, 120_086 ... 120_092, 120_094 ... 120_121, 120_123 ... 120_126, 120_128 ... 120_132, 120_134 ... 120_134, 120_138 ... 120_144, 120_146 ... 120_485, 120_488 ... 120_512, 120_514 ... 120_538, 120_540 ... 120_570, 120_572 ... 120_596, 120_598 ... 120_628, 120_630 ... 120_654, 120_656 ... 120_686, 120_688 ... 120_712, 120_714 ... 120_744, 120_746 ... 120_770, 120_772 ... 120_779, 123_136 ... 123_180, 123_191 ... 123_197, 123_214 ... 123_214, 123_584 ... 123_627, 124_928 ... 125_124, 125_184 ... 125_251, 125_259 ... 125_259, 126_464 ... 126_467, 126_469 ... 126_495, 126_497 ... 126_498, 126_500 ... 126_500, 126_503 ... 126_503, 126_505 ... 126_514, 126_516 ... 126_519, 126_521 ... 126_521, 126_523 ... 126_523, 126_530 ... 126_530, 126_535 ... 126_535, 126_537 ... 126_537, 126_539 ... 126_539, 126_541 ... 126_543, 126_545 ... 126_546, 126_548 ... 126_548, 126_551 ... 126_551, 126_553 ... 126_553, 126_555 ... 126_555, 126_557 ... 126_557, 126_559 ... 126_559, 126_561 ... 126_562, 126_564 ... 126_564, 126_567 ... 126_570, 126_572 ... 126_578, 126_580 ... 126_583, 126_585 ... 126_588, 126_590 ... 126_590, 126_592 ... 126_601, 126_603 ... 126_619, 126_625 ... 126_627, 126_629 ... 126_633, 126_635 ... 126_651, 127_280 ... 127_305, 127_312 ... 127_337, 127_344 ... 127_369)
private let regionalIndicator = Group(127_462 ... 127_487)
private let aHLetter = aLetter || hebrewLetter
private let midNumLetQ = midNumLet || singleQuote