Is Decimal by regex - CSharp System.Text.RegularExpressions

CSharp examples for System.Text.RegularExpressions:Match Number

Description

Is Decimal by regex

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using System.Linq;
using System.Collections.Generic;
using System;/*from   ww  w  .j av  a  2 s . c  o m*/

public class Main{
        public static bool IsDecimal(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                return false;
            }
            return Regex.IsMatch(input, @"^\d+[.]?\d*$");
        }
        public static bool IsNullOrEmpty(string value)
        {
            if (value == null)
            {
                return true;
            }

            return value.Trim().Length == 0;
        }
}

Related Tutorials