Consider changing AlphaRouteConstraint to use IndexOfAnyValues instead of Regex
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
Currently the `AlphaRouteConstraint` implementation uses a compiled regex to check to see whether a route value is composed entirely of alpha characters.
We are making a few changes in other areas of the code base to make use of `IndexOfAnyValues` to determine whether a string is composed soley of a limited set of characters. It got me thinking what the performance difference would look like using `IndexOfAnyValues` instead of the compiled regex.

Here is the corresponding code: https://gist.github.com/mitchdenny/3c6da9f9dd0589c424a5bdfd22239676
I brought this up in our teams chat and @JamesNK thought I should share it here and ping @stephentoub and @eerhardt.
> **NOTE**: The difference isn't as dramatic for very large string values (e.g. 400+ characters). I'm not sure if the lines ever intersect and Regex becomes faster or not - probably more of a case of the Regex overheads not mattering as much once you get to that size.
Contributor guide
Assessment
This issue has not been assessed yet.