I need to check if a string is only built up using 1, 0 and comma. It should also starts with either 0 or 1 and also ends with 0 or 1:
The checking for start and end can be done like this (Or if you think it can be improved peplase let me know!)
if ((text.StartsWith("0") || text.StartsWith("1")) //Starts with 0 or 1
&& (text.EndsWith("0") || text.EndsWith("1")) //Ends with 0 or 1
&& //How to check if it only has 0, 1 and comma? )
{
//Do Something!
}
You can use
Regex, try this: