Apple Text Regex & Parsing
Guides the implementation of Swift Regex and NSRegularExpression for Apple's text-editing stack, including TextKit and AttributedString bridging.
This skill provides specialized guidance for navigating the regex landscape in Apple development, helping developers choose between the modern Swift Regex engine and the legacy NSRegularExpression. It addresses the common 'match in the wrong place' problem by providing robust bridging patterns between String.Index and NSRange. Whether you're building a syntax highlighter, migrating legacy code, or extracting complex data types with Foundation parsers, this skill ensures Unicode-correct implementations and optimal performance across iOS and macOS text-editing frameworks.
Key Features
01Selection logic for choosing between Swift Regex and NSRegularExpression engines
02Type-safe capture parsing using Swift Regex literals and RegexBuilder DSL
030 GitHub stars
04Explicit bridging patterns between Range<String.Index> and NSRange
05Performance-optimized syntax highlighting patterns for TextKit and NSTextStorage
06Integration strategies for Foundation parsers like dates, currency, and integers
Use Cases
01Migrating legacy NSRegularExpression logic to modern, type-safe Swift Regex
02Extracting localized data points directly from text strings into strongly-typed values
03Implementing real-time syntax highlighting for a code editor using TextKit