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
Span<byte>.IndexOf(ReadOnlySpan<byte?> value) - Wildcard support #31307
Comments
@ahsonkhan speaking: @JeremyKuhne - the usage of this type of API shows up more commonly in file paths and IO/Regex. Should we consider providing this capability there rather than on the low-level span primitives? It will be hard to optimize/vectorize such an implementation. We would want to flesh out the API proposal more including the exact API shape in the proposal + details of the scenario: |
Yes. This is a very slippery slope towards full-blown regular expressions. We should not add such support to span directly or even to MemoryExtensions. We should instead figure out how to make it work with Regex or some derivation thereof. |
We need richer matching on cc: @eerhardt, @carlossanlop |
When you say "on Span", are you suggesting literally as members on the System.Span type? Or do you mean "for Span"? I'm strongly against the former. The latter makes sense, and is what #23602 is tracking. |
For |
In that case, anything we'd do here would be covered by #23602, so I'll close this. Thanks. |
Searching a byte or char array for a pattern is often being done and as of now requires the developer to fallback getting the first index match and then manually iterate through the array to see if it matches. Since the IndexOf method already accepts an array and C# has nullable support, it would be nice to have an extension method that allows wildcard support by passing a Span array of nullable byte/char.
APIs:
Example usage byte:
Example usage char:
The text was updated successfully, but these errors were encountered: