Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSRegularExpressionOptions? #3

Closed
sharplet opened this issue Oct 30, 2015 · 4 comments
Closed

NSRegularExpressionOptions? #3

sharplet opened this issue Oct 30, 2015 · 4 comments

Comments

@sharplet
Copy link
Owner

I'm personally fairly happy with the defaults, but if there's enough demand for some options it would be good to look into.

Case (in)sensitivity is one consideration.

@leotumwattana
Copy link

+1 for case (in)sensitivity

@sharplet
Copy link
Owner Author

Awesome. Are you interested in submitting a PR?

I've been thinking a little about the API—here's what I've come up with, for posterity.

I think this kind of thing is probably the most obvious:

Regex("foo", caseSensitive: false)
Regex("foo", ignoreCase: true)
Regex("foo", options: [.IgnoreCase])

It has the downside of being a little wordy though.

I'm not entirely opposed to using PCRE style options, specified as a second string:

Regex("foo", "i") // => /foo/i

It's not as user-friendly, but it's pretty standard these days, and I think the added brevity could be really nice.

@gfontenot
Copy link

I vote for Regex("foo", options: [.IgnoreCase]). Seems like it's a nice compromise between verbosity, flexibility, and ease of use.

@mokagio
Copy link

mokagio commented Nov 17, 2015

I'm on the Regex("pizza", options: [.IgnoreCase]) wagon too, in particular for the flexibility.

@sharplet sharplet mentioned this issue Dec 8, 2015
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants