I have the following code:
Match matcher = new Regex("[0-9]+.[0-9]+.[0-9]+").Match("12/02/1994");
if (matcher.Success)
{
string matchedString1 = matcher.Value;
string matchedString2 = matcher.ToString();
}
在这种情况下,
matchedString1
和matchedString2
包含相同的值"12/02/1994"
。对于任何正则表达式,matcher.Value
和matcher.ToString()
是否总是返回相同的结果?
ToString()
通常被实现为返回一些有助于在调试窗口中使用、连接对象等方面有用的内容。 - Miserable Variable