forked from liaozb/APIJSON.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringExtensions.cs
More file actions
39 lines (39 loc) · 1.15 KB
/
StringExtensions.cs
File metadata and controls
39 lines (39 loc) · 1.15 KB
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
namespace APIJSON.NET
{
using System;
using System.Text.RegularExpressions;
public static class StringExtensions
{
/// <summary>
/// 是否合法表名(大写字母数字下划线 长度在1-15之间)
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsTable(this string str)
{
return Regex.IsMatch(str, @"^[a-zA-Z][a-zA-Z0-9_]{1,15}$");
}
/// <summary>
///
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsField(this string str)
{
return Regex.IsMatch(str, @"^[a-zA-Z][a-zA-Z0-9_()]{1,15}$");
}
/// <summary>
/// 是否有值
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsValue(this object str)
{
return str != null && !string.IsNullOrEmpty(str.ToString());
}
public static string GetParamName(this string param)
{
return param + new Random().Next(1, 100);
}
}
}