文档
常用静态方法
Regex.IsMatch(input, regular) 判断input是否匹配regular
Regex.Match(input, regular) 返回符合regular的第一个Match
Regex.Matches(input, regular) 返回符合regular的多个Match
实例
string delimited = "[^a-x]";
string input = "abcdefghijklmnopqrstuvwxyz";
Debug.Log(Regex.IsMatch(input, delimited));//判断是否匹配 true
Debug.Log("单个:" + Regex.Match(input, delimited));//单个匹配结果 y
foreach (Match match in Regex.Matches(input, delimited))//多个匹配结果
{
Debug.Log("匹配結果:" + match.Value);//y z
}