Files
iFactory.Godot/BITKit/Scripts/Text/RegularExpressionResource.cs
CortexCore ca824c3b32 添加了标识更新
但是只有界面没有功能
2023-07-11 00:14:36 +08:00

26 lines
558 B
C#

using Godot;
using System;
using System.Runtime.InteropServices.ComTypes;
using System.Text.RegularExpressions;
using BITKit;
namespace BITKit;
[GlobalClass]
public partial class RegularExpressionResource : TextValidationResource
{
[Export] private string regex;
[Export] private string errorReason;
public override bool IsTextValid(string text, out string _errorReason)
{
switch (Regex.IsMatch(text, regex))
{
case true:
_errorReason = string.Empty;
return true;
case false:
_errorReason = errorReason;
return false;
}
}
}