有没有办法从根过滤数据?

时间:2012-11-27 13:08:33

标签: c# regex ms-access-2000

我可以从Web应用程序本身过滤数据,但是没有办法从root用户处理这个数据吗?

例如,过滤电话号码:+(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 
}

1 个答案:

答案 0 :(得分:0)

我得出结论,没有办法在早于编辑数据:

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));

所以我决定手动更改数据。