Unity Chan 工程分享 - URP渲染实现 Unity版本:2019.4
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

45 行
1.5 KiB

using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Unity.Animations.SpringBones
{
public class StringUtil
{
// OS-style glob matching
public static bool GlobMatch(string stringToCheck, string pattern)
{
// http://stackoverflow.com/a/4146349
return new Regex(
"^" + Regex.Escape(pattern).Replace(@"\*", ".*").Replace(@"\?", ".") + "$",
RegexOptions.IgnoreCase | RegexOptions.Singleline
).IsMatch(stringToCheck);
}
// Find first glob match in a list; returns null if no match
public static string GlobFind(IEnumerable<string> stringsToCheck, string pattern)
{
foreach (var stringToCheck in stringsToCheck)
{
if (GlobMatch(stringToCheck, pattern))
{
return stringToCheck;
}
}
return null;
}
// Find all glob matches in a list
public static List<string> GlobFindAll(IEnumerable<string> stringsToCheck, string pattern)
{
var matchedStrings = new List<string>();
foreach (var stringToCheck in stringsToCheck)
{
if (GlobMatch(stringToCheck, pattern))
{
matchedStrings.Add(stringToCheck);
}
}
return matchedStrings;
}
}
}