示例#1
0
 static private string ConvertPatternToRegex(string pattern)
 {
     return("^"
            + PathUtils.TrimEndSeparator(pattern)
            .Replace(@"/", @"\/")
            .Replace(@"\", @"\\")
            .Replace(@".", @"\.")
            .Replace("*", @"[^\/\\]*")
            .Replace("?", @"[^\/\\]?")
            + "$");
 }
示例#2
0
        static public string ApplyFolderEquality(string path, FolderPathEquality folderEquality)
        {
            if (path == null)
            {
                throw new ArgumentNullException();
            }

            if (folderEquality == FolderPathEquality.RespectAmbiguity)
            {
                path = PathUtils.TrimEndSeparator(path);
            }

            return(path);
        }
示例#3
0
        static public bool Match(string path, string pattern, bool caseSensitive = true)
        {
            if (!IsValid(pattern))
            {
                throw new ArgumentException();
            }

            if (IsSimplePath(pattern))
            {
                return(MatchSimplePath(path, pattern, caseSensitive));
            }

            var regexOptions = RegexOptions.None;

            if (!caseSensitive)
            {
                regexOptions |= RegexOptions.IgnoreCase;
            }

            return(Regex.IsMatch(PathUtils.TrimEndSeparator(path), ConvertPatternToRegex(pattern), regexOptions));
        }
示例#4
0
 public bool Match(string path)
 {
     return(_regex?.IsMatch(PathUtils.TrimEndSeparator(path)) ?? MatchSimplePath(path, Pattern, CaseSensitive));
 }