using System.Text.RegularExpressions;
namespace UnityEditor.Rendering
{
///
/// Set of utility functions with
///
public static class StringExtensions
{
private static Regex k_InvalidRegEx = new (string.Format(@"([{0}]*\.+$)|([{0}]+)", Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars()))), RegexOptions.Compiled);
///
/// Replaces invalid characters for a filename or a directory with a given optional replacemenet string
///
/// The input filename or directory
/// The replacement
/// The string with the invalid characters replaced
public static string ReplaceInvalidFileNameCharacters(this string input, string replacement = "_") => k_InvalidRegEx.Replace(input, replacement);
}
}