Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Regex support #74

Open
michaeleisel opened this issue Feb 2, 2015 · 2 comments
Open

Regex support #74

michaeleisel opened this issue Feb 2, 2015 · 2 comments

Comments

@michaeleisel
Copy link
Contributor

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:

let a: Regex = /"[0-9]*"

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?

@pNre
Copy link
Owner

pNre commented Feb 3, 2015

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.

@michaeleisel
Copy link
Contributor Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants