Regex.Match will return you a Match class instance that can be analyzed deeply about what is to be matched. But Regex.isMatch only tells you whether the fixed string matches the Regex expression or not.
See the reflected codeso of Regex class:
【Regex's Match】
public static Match Match(string input, string pattern)
{
return (new Regex(pattern, RegexOptions.None, true)).Match(input);
}
public static Match Match(string input, string pattern, RegexOptions options)
{
return (new Regex(pattern, options, true)).Match(input);
}
public Match Match(string input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
return this.Run(false, -1, input, 0, input.Length, (this.UseOptionR() ? input.Length : 0));
}
public Match Match(string input, int startat)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
return this.Run(false, -1, input, 0, input.Length, startat);
}
public Match Match(string input, int beginning, int length)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
return this.Run(false, -1, input, beginning, length, (this.UseOptionR() ? beginning + length : beginning));
}
【Regex's IsMatch】
public static bool IsMatch(string input, string pattern)
{
return (new Regex(pattern, RegexOptions.None, true)).IsMatch(input);
}
public static bool IsMatch(string input, string pattern, RegexOptions options)
{
return (new Regex(pattern, options, true)).IsMatch(input);
}
public bool IsMatch(string input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
return null == this.Run(true, -1, input, 0, input.Length, (this.UseOptionR() ? input.Length : 0));
}
public bool IsMatch(string input, int startat)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
return null == this.Run(true, -1, input, 0, input.Length, startat);
}
ASP.NET Questions
Other Discussions
FreeRice Donate
Issues to report
No comments:
Post a Comment