Files
BuYuHouDuan/Infrastructure/Common/BlockWord/BlockWordHelper.cs
T

37 lines
1.1 KiB
C#
Raw Normal View History

2026-10-12 16:22:04 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ToolGood.Words;
namespace Common.BlockWord
{
public static class BlockWordHelper
{
public static bool IsHaveBlockWord(string text)
{
if (string.IsNullOrWhiteSpace(text))
return false;
StringSearch iwords = new StringSearch();
iwords.SetKeywords(BlockWord.BlockWordValue.Split(','));
return iwords.ContainsAny(text);
}
public static string ReplaceBlockWord(string text, char replaceChar = '*')
{
StringSearch iwords = new StringSearch();
iwords.SetKeywords(BlockWord.BlockWordValue.Split(','));
return iwords.Replace(text, replaceChar);
}
public static List<string> GetBlockWord(string text)
{
if (string.IsNullOrWhiteSpace(text))
return null;
StringSearch iwords = new StringSearch();
iwords.SetKeywords(BlockWord.BlockWordValue.Split(','));
return iwords.FindAll(text);
}
}
}