敏感词处理

xiaoxiao2021-02-27  372

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; namespace 敏感词处理 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //审核的 StringBuilder sbMod = new StringBuilder(); //禁止的 StringBuilder sbBanned = new StringBuilder(); private void Form1_Load(object sender, EventArgs e) { //读取文件 string[] lines = File.ReadAllLines("mg.txt", Encoding.Default); for(int i=0;i<lines.Length;i++) { //切掉每行的= string[] txts = lines[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (txts[1] == "{MOD}") { sbMod.Append(txts[0] + "|");//最后一个元素后面,多了一个| } else if (txts[1] == "{BANNED}") { sbBanned.Append(txts[0] + "|"); } } sbMod.Remove(sbMod.Length - 1, 1); sbBanned.Remove(sbBanned.Length - 1, 1); } private void button1_Click(object sender, EventArgs e) { if (Regex.IsMatch(textBox1.Text, sbMod.ToString())) { MessageBox.Show("该内容需要审核之后,再发贴"); } else if(Regex.IsMatch(textBox2.Text,sbBanned.ToString())) { MessageBox.Show("禁止发帖"); } else { textBox2.Text = textBox1.Text; } } } }
转载请注明原文地址: https://www.6miu.com/read-4090.html

最新回复(0)