glob pattern matching in .NET

后端 未结 14 1430
遇见更好的自我
遇见更好的自我 2020-11-29 01:52

Is there a built-in mechanism in .NET to match patterns other than Regular Expressions? I\'d like to match using UNIX style (glob) wildcards (* = any number of any characte

14条回答
  •  死守一世寂寞
    2020-11-29 02:14

    Just for the sake of completeness. Since 2016 in dotnet core there is a new nuget package called Microsoft.Extensions.FileSystemGlobbing that supports advanced globing paths. (Nuget Package)

    some examples might be, searching for wildcard nested folder structures and files which is very common in web development scenarios.

    • wwwroot/app/**/*.module.js
    • wwwroot/app/**/*.js

    This works somewhat similar with what .gitignore files use to determine which files to exclude from source control.

提交回复
热议问题