コード例 #1
0
        public Regex CompileRegex(string globPattern, FileSystemCasing casing)
        {
            var normalisedGlobPattern = SquashDirectorySeparators(globPattern);
            var regexPattern          = new Internal().Compile(normalisedGlobPattern);

            return(FileSystemRegexHelpers.CreateRegex(regexPattern, casing));
        }
コード例 #2
0
        public Regex CompileRegex(string fileExtension, FileSystemCasing casing)
        {
            var trimmed = fileExtension.TrimStart('.');

            if (fileExtension.Length - trimmed.Length > 1)
            {
                throw new FileExtensionFormatException("Multiple leading dots are not permitted.", fileExtension);
            }

            var regexPattern = $@"^.*\.{Regex.Escape(trimmed)}$";

            return(FileSystemRegexHelpers.CreateRegex(regexPattern, casing));
        }