Open michaeleisel opened 9 years ago
Since there's a lot of stuff that we can do with regexps, we should consider starting a new library/framework, something like a Swift version of RegExKit meets ruby (and maybe more).
And yes, using NSRegularExpression
it's the most reasonable option in order to offer a consistent interface to the iOS/OS X frameworks.
I'll be traveling for a while so I don't want to maintain a library like that, but this summer I might be around to help.
I was thinking, since Google doesn't turn up any authoritative Regex Swift libraries, Regex would be a good idea. I haven't heard of any way to write out a Regex pattern without it being escaped, but oh well. I was thinking of adding a prefix operator, "/", that takes a String, so you would define a Regex literal like this:
I would also add the =~ operator, a subscript lookup on strings, and almost all of Ruby's stuff for regexes, which you can find by searching for "regexp" on this page: http://www.ruby-doc.org/core-2.2.0/String.html
One question is whether or not to use iOS's existing regular expression class, NSRegularExpression. I don't know a lot about it, but it seems to reasonable to just make extension methods for it as needed, and perhaps subclass it as we need in the future.
Thoughts?