Showing posts with label regex validate number starting zero. Show all posts
Showing posts with label regex validate number starting zero. Show all posts

Sunday, August 22, 2021

numeric textbox (first number can't be 0)

 I wanted to validate a textbox with a number not starting with zero. For this I used Regex as displayed below.

       Regex reg = null;
       reg = new System.Text.RegularExpressions.Regex("^[1-9]\d*$")
       return reg.IsMatch(str);

Cheers

Samitha