We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the solution you'd like
Supporting range: NSRange in the Search API like snippets below
range: NSRange
public struct SearchQuery: Hashable, Equatable { + /// The range to search in + public let range: NSRange? - public init(text: String, matchMethod: MatchMethod = .contains, isCaseSensitive: Bool = false) { + public init(text: String, matchMethod: MatchMethod = .contains, isCaseSensitive: Bool = false, range: NSRange? = nil) { func matches(in string: NSString) -> [NSTextCheckingResult] { do { let regex = try NSRegularExpression(pattern: annotatedText, options: regularExpressionOptions) - return regex.matches(in: string as String, range: NSRange(location: 0, length: string.length)) + return regex.matches(in: string as String, range: range ?? NSRange(location: 0, length: string.length)) } catch { #if DEBUG print(error) #endif return [] } }
Supporting search in specified ranges would allow embedders to control where the search should happen, making it possible to build features like
Describe alternatives you've considered
We could search in all text and then do the filtering afterwards but that would be less performant.
I can send PRs if this makes sense to you.
The text was updated successfully, but these errors were encountered:
This sounds like a great addition. I'll be happy to merge a PR that introduces this functionality.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Describe the solution you'd like
Supporting
range: NSRange
in the Search API like snippets belowSupporting search in specified ranges would allow embedders to control where the search should happen, making it possible to build features like
Describe alternatives you've considered
We could search in all text and then do the filtering afterwards but that would be less performant.
I can send PRs if this makes sense to you.
The text was updated successfully, but these errors were encountered: