Archived
1
0

统一归档20260319

This commit is contained in:
2026-03-19 19:39:01 +08:00
Unverified
parent 4e148364a9
commit 3ea0af246b
187 changed files with 5041 additions and 75005 deletions
+30
View File
@@ -0,0 +1,30 @@
using System.Text.RegularExpressions;
namespace _10_6
{
internal class Program
{
static void Main(string[] args)
{
// 验证中国电话号码
string pattern = @"(\^(\d{3}\ )|\d{3}-)?\d{8}$";
Console.WriteLine("请输入字符串(中国电话号码)");
string s = Console.ReadLine();
bool b1 = Regex.IsMatch(s, pattern);
Console.WriteLine("{0}是有效的中国电话号码吗? {1}", s, b1);
// 验证邮政编码
pattern = @"^\d{6}$";
Console.WriteLine("请输入字符串(邮政编码)");
s = Console.ReadLine();
bool b2 = Regex.IsMatch(s, pattern);
Console.WriteLine("{0}是有效的邮政编码吗? {1}", s, b2);
// 有效URL地址
pattern = @"^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$";
Console.WriteLine("请输入字符串(URL地址)");
s = Console.ReadLine();
bool b3 = Regex.IsMatch(s, pattern);
Console.WriteLine("{0}是有效的URL地址吗? {1}", s, b3);
Console.ReadLine();
}
}
}