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

Regular expression support #85

Closed
coryroloff opened this issue Jul 25, 2014 · 10 comments
Closed

Regular expression support #85

coryroloff opened this issue Jul 25, 2014 · 10 comments

Comments

@coryroloff
Copy link

Just curious if you would consider adding helpers for NSRegularExpression. Apple's regex library is good, but it's a painful API to use and maintain. Otherwise, loving the library you've built!

@ankurp
Copy link
Owner

ankurp commented Jul 25, 2014

Thanks! Yes it makes sense to add helper methods for regex or even creating extensions for NSRegularExpression in the Cent library if it makes sense. Let me know if you need help implementing.

@coryroloff
Copy link
Author

How do you determine which APIs should be in Dollar and which should be extensions in Cent?

We could do something for regular expressions like:

$.test("^some sort of regex$", "data to test against") -> true/false

or this maybe? "data to test against".match("^some sort of regex$")

Each API could accept both a string and an NSRegularExpression object. Thoughts?

@nubbel
Copy link
Contributor

nubbel commented Jul 26, 2014

I have created a Swift port of VerbalExpressions: https://github.com/VerbalExpressions/SwiftVerbalExpressions
Would that be something for you or is it too much sugar?

@coryroloff
Copy link
Author

VertbalExpressions looks really good, nubbel; I'll try it out. I think having basic regular expression support in Dollar is still valuable though.

@ankurp
Copy link
Owner

ankurp commented Jul 26, 2014

I would make a functional method in Dollar and have the String class extension implement a match method using the functional implementation imported from Dollar

@ankurp
Copy link
Owner

ankurp commented Aug 10, 2014

Made any progress with this or need some help?

@coryroloff
Copy link
Author

Hey ankurp, sorry, I haven't had much time. I'll try to get you a pull request tomorrow. :) Sorry for the wait.

@ankurp
Copy link
Owner

ankurp commented Aug 10, 2014

@coryroloff No problem. Let me know if you run into any issues running tests as currently I am not able to get the test to run due to Swift and SourceKit hogging all of the CPU and memory in Xcode Beta5

@coryroloff
Copy link
Author

I run into the same issue, but I commented out the other tests for now. Unfortunately, Beta5 is throwing an exception with the NSRegularExpression class, which Beta4 had no trouble with.

Even just running this example of using NSRegularExpression causes the runtime to fail. It throws an exception on the "regex.matchesInString" method (and the other match methods as well) with the error:

dyld: lazy symbol binding failed: Symbol not found: _objc_readClassPair

Have you run into this issue before?


var error: NSError?

let string = "data to match"
let regex = NSRegularExpression(pattern: ".*", options: nil, error: &error)

assert(error == nil)

var matches = regex.matchesInString(string, options: nil, range: NSMakeRange(0, countElements(string)))

@ankurp
Copy link
Owner

ankurp commented Oct 23, 2014

Done

@ankurp ankurp closed this as completed Oct 23, 2014
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

3 participants