I am looking for a regex to accept only numbers and comma but not 0,decimal,special characters,negative numbers and white-space between the numbers.It can allow White-space at the start and end of the value.Also It should allow 0 for 10,100,20 but I don't want the textbox to allow a single digit zero.
I have tried multiple options but I couldn't find one that solve my problem.
string testAnswer = textbox.value;
Regex answerRegex = new Regex(@"\s+(?<!-)[1-9][0-9,]*\s+");
if (testAnswer.Contains(","))
{
testAnswer = testAnswer.Replace(",", "");
Response.Write(testAnswer);
}
Match answerMatch = answerRegex.Match(testAnswer.Trim());
if (testAnswer == String.Empty || !answerMatch.Success)
{
valid = false;
answer.CssClass = "error";
}
else
{
answer.CssClass = "comp";
}