init: 导入项目到 meswork Gitea
This commit is contained in:
32
DataMirrorTools_Simulator/ModelBasic/BasicClass/Judge.cs
Normal file
32
DataMirrorTools_Simulator/ModelBasic/BasicClass/Judge.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModelBasic
|
||||
{
|
||||
public class Judge
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否是int/double
|
||||
/// </summary>
|
||||
public static bool IsIntOrDouble(string strNumber)
|
||||
{
|
||||
var objNotNumberPattern = new Regex("[^0-9.-]");
|
||||
var objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
|
||||
var objTwoMinusPattern = new Regex("[0-9]*[-][0-9]*[-][0-9]*");
|
||||
const string strValidRealPattern = "^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$";
|
||||
const string strValidIntegerPattern = "^([-]|[0-9])[0-9]*$";
|
||||
var objNumberPattern = new Regex("(" + strValidRealPattern + ")|(" + strValidIntegerPattern + ")");
|
||||
return !objNotNumberPattern.IsMatch(strNumber) &&
|
||||
!objTwoDotPattern.IsMatch(strNumber) &&
|
||||
!objTwoMinusPattern.IsMatch(strNumber) &&
|
||||
objNumberPattern.IsMatch(strNumber);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user