Use the pattern-matching Force.
Use the pattern-matching Force.
I’ve loved regular expressions since the beginning of my programming career back when I worked at Apple. I learned (and continue to learn) A LOT from Jeffrey Friedl’s book, Mastering Regular Expression, 3rd. ed. I know they are controversial in some circles but when crafted well, there’s really nothing like them.
Here’s some follow-up reading about regexes:
This is a Regular Expression API inspired by the RegexKitLite 4.0 API that John Engelhart (@johnezang) shipped back in 2010. (“RKL4“)
Basically, I’m modernizing the API as a cover for NSRegularExpression and NSTextCheckingResult.
I am doing this for several reasons:
OSSpinLock
-based deprecation warnings on macOS 10.12 Sierra and aboveMy concern is that no amount of work-arounds or modifications to all the low-level RKL4 magic code will save it from being unbuildable or free of static analyzer warnings in a future appleOS. So rather than wait for that to happen or repeatedly deal directly with the awkwardness of NSRegularExpression, I’m choosing to do RegexKitX (“RKX“).
I’ve also added documentation that is option-clickable for all the RKX category methods.
NOTE: There’s an almost-pure RKL4 API re-implementation here. This version is intended to be a drop-in replacement (with possible block-based modifications) for the original RKL4 codebase.
NSEnumerationOptions
to provide an option for directional control of the enumeration. As usual, NSEnumerationConcurrent
behavior is undefined.I have deprecated the SwiftRegexKitX extension and tests. The new Apple Swift Regex additions pretty much negate any prior extensions. Apple has added a Regex
struct and associated types along with a RegexBuilder DSL, which is much more sophisticated than anything I came up with for SwiftRegexKitX.