Files
MinFt/Client/LocalPackages/SoftMaskForUGUI-3.5.0/Editor/Internal/AssetModification/TextReplaceModifier.cs
2026-04-27 12:07:32 +08:00

26 lines
654 B
C#

using System.Text;
using System.Text.RegularExpressions;
namespace Coffee.UISoftMaskInternal.AssetModification
{
internal class TextReplaceModifier : ITextModifier
{
private readonly Regex _pattern;
private readonly string _replace;
public TextReplaceModifier(string pattern, string replace)
{
_pattern = new Regex(pattern);
_replace = replace;
}
public bool ModifyText(StringBuilder sb, string text)
{
if (!_pattern.IsMatch(text)) return false;
sb.AppendLine(_pattern.Replace(text, _replace));
return true;
}
}
}