schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
 
namespace XCommon.Check.Data
{
    public class ValidateData
    {
        private static Regex RegNumber = new Regex("^[0-9]+$");
        private static Regex RegDecimal = new Regex("^[0-9]+[.]?[0-9]+$");
        private static Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$");
 
        
 
 
        /// <summary>
        /// 是否为ip
        /// </summary>
        /// <param name="inputData"></param>
        /// <returns></returns>
        public static bool IsIp(string inputData)
        {
            return Regex.IsMatch(inputData, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
        }
 
 
        #region 数字字符串检查       
        /// <summary>  
        /// 是否为数字
        /// </summary>  
        /// <param name="inputData"& gt;输入字符串</param>  
        /// <returns></returns>  
        public static bool IsNumber(string inputData)
        {
            Match m = RegNumber.Match(inputData);
            return m.Success;
        }
 
        /// <summary>  
        /// 是否是浮点数  
        /// </summary>  
        /// <param name="inputData"& gt;输入字符串</param>  
        /// <returns></returns>  
        public static bool IsDecimal(string inputData)
        {
            Match m = RegDecimal.Match(inputData);
            return m.Success;
        }
        #endregion
 
        #region 邮件地址  
        /// <summary>  
        /// 是否是浮点数 可带正负号  
        /// </summary>  
        /// <param name="inputData"& gt;输入字符串</param>  
        /// <returns></returns>  
        public static bool IsEmail(string inputData)
        {
            Match m = RegEmail.Match(inputData);
            return m.Success;
        }
        #endregion
 
 
    }
}