public Regex CompileRegex(string globPattern, FileSystemCasing casing) { var normalisedGlobPattern = SquashDirectorySeparators(globPattern); var regexPattern = new Internal().Compile(normalisedGlobPattern); return(FileSystemRegexHelpers.CreateRegex(regexPattern, casing)); }
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)); }