日期:2014-05-18 浏览次数:20820 次
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Text.RegularExpressions; using System.IO; public partial class dotext_tel : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { TD1.Visible = true; TD2.Visible = true; } } protected void Button1_Click(object sender, EventArgs e) { File.AppendAllText(Server.MapPath("/") + "upload/zhengli/原文件" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt", TextBox1.Text); string otel = TextBox1.Text; //string ntel = ""; string onetel = ""; string etel = ""; string quhao = TextBox4.Text.Trim(); string yidong = ""; string liantong = ""; string xiaolingtong = ""; string[] thetel = otel.Split(new string[] { "\r\n", ",", "、", "\\", "/", " ", "(", ")", ";", ":" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < thetel.Length; i++) { onetel = thetel[i].Trim(); if (Regex.IsMatch(onetel, @"^1[3,5][0-9]{9}$"))//标准手机号码 { if (isliantong(onetel)) { liantong = liantong + onetel + "\r\n"; } else { yidong = yidong + onetel + "\r\n"; } } else if (Regex.IsMatch(onetel, @"^\+861[3,5][0-9]{9}$"))//不标准手机号码,带+86的 { onetel = onetel.Substring(4); if (isliantong(onetel)) { liantong = liantong + onetel + "\r\n"; } else { yidong = yidong + onetel + "\r\n"; } } else if (Regex.IsMatch(onetel, @"^01[3,5][0-9]{9}$"))//0开头的手机号码 { onetel = onetel.Substring(2); if (isliantong(onetel)) { liantong = liantong + onetel + "\r\n"; } else { yidong = yidong + onetel + "\r\n"; } } else//手机号码判断完毕后,其他的为小灵通号码 { if (Regex.IsMatch(onetel, @"^0[1-9][0-9]{8,10}$"))//带区号的小灵通号码 { xiaolingtong = xiaolingtong + onetel + "\r\n"; } else if (Regex.IsMatch(onetel, @"^0[1-9][0-9]{1,2}[\-][1-9][0-9]{6,7}$"))//带-的号码 { xiaolingtong = xiaolingtong + onetel.Replace("-", "") + "\r\n"; } else if (Regex.IsMatch(onetel, @"^[1-9][0-9]{6,7}$"))//不带区号的小灵通号码(7或8位数字) { if ((onetel.Length + quhao.Length) == 10)//区号+小灵通号码等于10位不存在的号码 { etel = etel + onetel + "\r\n"; } else { xiaolingtong = xiaolingtong + quhao + onetel + "\r\n"; } } else if (Regex.IsMatch(onetel, @"^1060[1-9][0-9]{8,10}$"))//带106前缀的小灵通号码