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

How can I get the matched range? #26

Closed
singno opened this issue Dec 23, 2015 · 5 comments
Closed

How can I get the matched range? #26

singno opened this issue Dec 23, 2015 · 5 comments

Comments

@singno
Copy link

singno commented Dec 23, 2015

No description provided.

@sharplet
Copy link
Owner

sharplet commented Jan 2, 2016

Hi @singno!

This is something I've considered, however I'd like to talk about concrete use cases before adding it. Would you mind elaborating on your use case?

@sharplet
Copy link
Owner

Just FYI, I ended up adding a range property to MatchResult as part of #31. If you think there's a compelling use case for it beyond find and replace, I'll definitely consider going ahead and making it public!

@singno
Copy link
Author

singno commented Jan 14, 2016

It sounds great! And sometimes I want to replace part of NSAttributedString, would you also support this use cases?

@sharplet
Copy link
Owner

sharplet commented Feb 1, 2016

@singno I've just released version 0.3.1 which includes range replacement methods.

At this stage I think NSAttributedString integration is out of scope for this library. Because NSRegularExpression itself doesn't have direct integration with NSAttributedString.

However, it may be worth exposing a utf16range property on MatchResult, which you could then pass to NSMutableAttributedString.replaceCharactersInRange(_:withString:) et al. Would that work for your use case?

@sharplet
Copy link
Owner

sharplet commented Mar 2, 2016

NSAttributedString support has come up in another issue as well, so I've opened #38 to track that into the future. I'm going to close this for now.

@sharplet sharplet closed this as completed Mar 2, 2016
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

2 participants