@@ -1683,6 +1683,38 @@ extension RegexTests {
1683
1683
firstMatchTest ( #"\b÷\b"# , input: " 3 ÷ 3 = 1 " , match: " ÷ " )
1684
1684
}
1685
1685
1686
+ func testLevel2WordBoundaries_2( ) throws {
1687
+ let re = try ! Regex ( #"\bA\b"# )
1688
+
1689
+ // OK: Space after colon works (note "NO ENTRY" emoji has U+FE0F after it)
1690
+ try print ( re. firstMatch ( in: " ⛔️: X " ) == nil ) // => true
1691
+ try print ( re. firstMatch ( in: " 日 \u{FE0F} : X " ) == nil ) // => true
1692
+ try print ( re. firstMatch ( in: " 👨👨👧👦 \u{FE0F} : X " ) == nil ) // => true
1693
+
1694
+ // OK: No U+FE0F to left of colon, no space after colon
1695
+ try print ( re. firstMatch ( in: " Z:X " ) == nil ) // => true
1696
+
1697
+ // OK: Alphabetic followed by U+FE0F to left of colon
1698
+ try print ( re. firstMatch ( in: " Z \u{FE0F} :X " ) == nil ) // => true
1699
+ try print ( re. firstMatch ( in: " è \u{FE0F} :X " ) == nil ) // => true
1700
+
1701
+ // OK: Non-alphabetic without U+FE0F
1702
+ try print ( re. firstMatch ( in: " 日:X " ) == nil ) // => true
1703
+ try print ( re. firstMatch ( in: " 👨👨👧👦:X " ) == nil ) // => true
1704
+
1705
+ print ( " all the rest hang... " )
1706
+
1707
+ // HANGS: Non-alphabetic followed by U+FE0F to left of colon (note "NO ENTRY" emoji has U+FE0F)
1708
+ try print ( re. firstMatch ( in: " 日 \u{FE0F} :X " ) == nil ) // => HANGS!
1709
+ try print ( re. firstMatch ( in: " 👨👨👧👦 \u{FE0F} :X " ) == nil ) // => HANGS!
1710
+ try print ( re. firstMatch ( in: " ⛔️:X " ) == nil ) // => HANGS!
1711
+
1712
+ // HANGS: Other MidLetters as well, not just colon (note "NO ENTRY" emoji has U+FE0F)
1713
+ try print ( re. firstMatch ( in: " ⛔️·X " ) == nil ) // => HANGS!
1714
+ try print ( re. firstMatch ( in: " ⛔️:X " ) == nil ) // => HANGS!
1715
+
1716
+ }
1717
+
1686
1718
func testMatchGroups( ) {
1687
1719
// Must have new stdlib for character class ranges and word boundaries.
1688
1720
guard ensureNewStdlib ( ) else { return }
@@ -2717,4 +2749,14 @@ extension RegexTests {
2717
2749
XCTAssertNotNil ( str. wholeMatch ( of: possessiveRegex) )
2718
2750
}
2719
2751
}
2752
+
2753
+ func testFoo( ) throws {
2754
+ let re = try Regex ( #"^[\u{0000}-\u{024F}]+$"# )
2755
+
2756
+ XCTAssertNotNil ( " aaa " . wholeMatch ( of: re) )
2757
+ XCTAssertNotNil ( " aa \u{301} a " . wholeMatch ( of: re) )
2758
+ XCTAssertNil ( " aa \u{301} \u{302} a " . wholeMatch ( of: re) )
2759
+ }
2720
2760
}
2761
+
2762
+
0 commit comments