解决方案 »

  1.   

    你要了解的是*代表什么 ?代表什么*是任意N个字符  ?是任意1个字符正则当然可以,你要1个char1个char比对也是可以的 比如kmp算法查找字符串,你可以加入*处理和?处理等,不过还是建议你用正则,不要重复造轮子,但是如果只是研究 你可以试试 
      

  2.   

    一般* ?通配符常用于匹配文件路径,NuGet的PathResolver类就是一个通配符转正则,匹配文件路径的工具。不但支持 * ? 还支持**匹配任意深度路径,可以参考。
      

  3.   

    LikeOperator.LikeString 方法
    .Net 框架自带算法,不需要使用第三方库
      

  4.   

    要导入Microsoft.VisualBasic.CompilerServices库,我的win7下的vs2008,每次点导入都有可能失去响应,试试先了解,意思是把原来字符串的abc*.txt换成abc\*.txt就变成了正则表达式了。找到了
    private static Regex WildcardToRegex(string wildcard)
            {
                var pattern = Regex.Escape(wildcard);
                if (Path.DirectorySeparatorChar == '/')
                {
                    // regex wildcard adjustments for *nix-style file systems
                    pattern = pattern
                        .Replace(@"\*\*/", ".*") //For recursive wildcards /**/, include the current directory.
                        .Replace(@"\*\*", ".*") // For recursive wildcards that don't end in a slash e.g. **.txt would be treated as a .txt file at any depth
                        .Replace(@"\*", @"[^/]*(/)?") // For non recursive searches, limit it any character that is not a directory separator
                        .Replace(@"\?", "."); // ? translates to a single any character
                }
                else
                {
                    // regex wildcard adjustments for Windows-style file systems
                    pattern = pattern
                        .Replace("/", @"\\") // On Windows, / is treated the same as \.
                        .Replace(@"\*\*\\", ".*") //For recursive wildcards \**\, include the current directory.
                        .Replace(@"\*\*", ".*") // For recursive wildcards that don't end in a slash e.g. **.txt would be treated as a .txt file at any depth
                        .Replace(@"\*", @"[^\\]*(\\)?") // For non recursive searches, limit it any character that is not a directory separator
                        .Replace(@"\?", "."); // ? translates to a single any character
                }            return new Regex('^' + pattern + '$', RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);
            }
    一个个的试试,多谢几位