我可以从Web应用程序本身过滤数据,但是没有办法从根部处理这个问题吗?
例如,筛选电话号码:+(12)345 678 91 /011
通过 Web 应用程序使用正则表达式,我目前正在这样做:
bool validPhoneNumber = Common.IsValidTelephoneNumber(this.PhoneNumber);
//Insert Regular Expression
Regex regex = new Regex(@"^((((+|00){3})|(()?d{3}()?|)d{10})$")
string number = this.PhoneNumber;
// Replace unwanted Characters
number.Replace(" ", "");
number.Replace("-", "");
number.Replace("(", "");
number.Replace(")", "");
number.Replace(":", "");
Match match = regex.Match(number);
PhoneNumber (Contact)
char[] phonenumber = this.phoneNumber.ToCharArray();
StringBuilder builder = new StringBuilder(10);
for (int i = 0; i < phonenumber.Length; i++)
{
if (phonenumber[i] >= '0' && phonenumber[i] <= '9')
{
builder.Append(phonenumber[i]);
}
}
phoneNumber = builder.ToString().Substring(0, Math.Min(10, builder.Length));
//OUTPUT: +1234567891
我想做的是收集数据,然后更新它;
using (test.Database.OleDB db = new OleDB(OleDBConn)) {
db.Sql =
"UPDATE [Contact] SET ([MobileNumber]) VALUES " + "(@mobileNumber)" +
"WHERE [Contact_ID] = @contactId";
db.SetSqlParam("mobileNumber", MobileNumber);
db.Handle.ExecuteNonQuery(); // Update the Record
}
我得出的结论是,无法在以下时间之前编辑数据:
bool validPhoneNumber = Common.IsValidTelephoneNumber(this.PhoneNumber);
//Insert Regular Expression
Regex regex = new Regex(@"^((((+|00){3})|(()?d{3}()?|)d{10})$")
string number = this.PhoneNumber;
// Replace unwanted Characters
number.Replace(" ", "");
number.Replace("-", "");
number.Replace("(", "");
number.Replace(")", "");
number.Replace(":", "");
Match match = regex.Match(number);
PhoneNumber (Contact)
char[] phonenumber = this.phoneNumber.ToCharArray();
StringBuilder builder = new StringBuilder(10);
for (int i = 0; i < phonenumber.Length; i++)
{
if (phonenumber[i] >= '0' && phonenumber[i] <= '9')
{
builder.Append(phonenumber[i]);
}
}
phoneNumber = builder.ToString().Substring(0, Math.Min(10, builder.Length));
所以我决定手动更改数据。