[API Proposal]: add regex for pattern matching
balakhaniyan opened this issue · 1 comments
balakhaniyan commented
Background and motivation
Hello
Can dotnet team add a feature to pattern matching to use RegEx? (with is
keyword)
API Proposal
I think there is no need to submit an API proposal
API Usage
if (data is @"\s+") {
}
Alternative Designs
No response
Risks
No response
huoyaoyuan commented
This is a C# language feature and belongs to https://github.com/dotnet/csharplang/discussions.
Testing IsMatch
itself will definitely not be a language feature. It's just a shorthand of one method Regex.IsMatch
. This falls under user-defined active pattern, which is discussed at #277 and #4131 .
The more interesting case is to extract the matched captures directly as variables, like the opposite of string interpolation.