glob模式匹配的.NET [英] glob pattern matching in .NET

查看:177
本文介绍了glob模式匹配的.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有在.NET中内置的机制来匹配模式比普通防爆pressions其他?我想使用UNIX风格(水珠)通配符(* =任意数量的任何字符)相匹配。

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 character).

我想利用这个为面临控制最终用户。我担心,允许所有的正则表达式的能力将是非常混乱的。

I'd like to use this for a end-user facing control. I fear that permitting all RegEx capabilities will be very confusing.

推荐答案

我发现实际$ C $下您:

I found the actual code for you:

Regex.Escape( wildcardExpression ).Replace( @"\*", ".*" ).Replace( @"\?", "." );

这篇关于glob模式匹配的.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆