我在網絡上發現了這種模式,除了這種模式外,我還測試了幾個,它們都失敗了,但它們只在成功時失敗。正則表達式不起作用。獲取堆棧溢出錯誤
public string Address {
get
{
return this.Address;
}
private set
{
string emailPattern = @"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
+ "@"
+ @"((([\-\w]+\.)+[a-zA-Z]{2,4}))"
+ "|"
+ @"(([0-9]{1,3}\.){3}[0-9]{1,3}))\z";
if (Regex.IsMatch(value, emailPattern))
{
this.Address = value;
}
else
{
throw new Exception(value + " doesn't seem to be a valid email address.");
}
}
吸氣將挑起'StackOverflowException'以及! – Vache
是的,它真的,對不起,我只看着二傳手 –