1. 程式人生 > >使用正則表示式驗證月份

使用正則表示式驗證月份

實現效果:

運用知識:

實現程式碼:

        //定義方法
        public bool IsValidate(string str_month) {
            return System.Text.RegularExpressions.
                Regex.IsMatch(str_month,@"(^0?[0-9]$|^1[0-2]$)");
        }