I have a form that validates string with this:
[RegularExpression(@"[a-zA-Z]+[a-zA-Z\d_]*[a-zA-Z\d]")]
[MinLength(5)]
[Required]
public string JoinLink { get; set; }
this statement accepts anything that start with alphabetic and after that _ or digit or word and the end just word and digit. example:
asdfg123 //match
123546asdfa //not match
asdf1235_ //not match
https://telegram.me/agdfgkjafdg16456 // not match
in other hand when user upload excel file i have to check that content is correct.like this:
string reg = @"^[a-zA-Z]+[a-zA-Z\d_]*[a-zA-Z\d]";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string link = ds.Tables[0].Rows[i][0].ToString();
bool result = Regex.IsMatch(link, reg);
if (result)
{
//Do somthing
}
Everything is ok until a string is https://telegram.me/... or any address. why result for addresses is true?
Can you help me ?
Thanks in advance