端口正则:
string pattrn = "^[0-9]+$";
if (System.Text.RegularExpressions.Regex.IsMatch(PorttextBox.Text.Trim(), pattrn)){};
IP正则:
string _pattrn = @"(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])";
if (System.Text.RegularExpressions.Regex.IsMatch(this.IptextBox.Text, _pattrn)){};