初学者需要帮助!!!! [英] Beginner Need Help!!!!

查看:114
本文介绍了初学者需要帮助!!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Richtext框上进行简单搜索,使用网络表单应用程序

我创建了一个搜索按钮,TextBox和一个RichtextBox

我需要消除这些来自用户在搜索框中输入的单词

这些单词是



(and,and,to,that,in,he,应该,因为,我,他,他们,他们,是,是,不是,他,他们,你,你,是,你,我,我,我)



代码为:

I am doing a simple search on Richtext box, using web form application
I created a "Search" button, TextBox and a RichtextBox
I need to eliminate these word from user typing in the search box
The words are

(the, and, of, to, that, in, he, shall, for, unto, i, his, a, they, be, is, not, him, them, it, with, all, thou, was, thy, which, my, me)

The Code is:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace search_bar_w_richtextbox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int index = 0;
            while (index < richTextBox1.Text.LastIndexOf(textBox1.Text))
            {
                richTextBox1.Find(textBox1.Text, index, richTextBox1.TextLength, RichTextBoxFinds.None);
                richTextBox1.SelectionBackColor = Color.Green;
                index = richTextBox1.Text.IndexOf(textBox1.Text, index) + 1;
            }
        }
    }
}





如果有人知道如何消除来自用户输入的那些词,

你能发布完整的代码!!!!



If any one know how to eliminate those word from user typing,
Can you post the full Code !!!!

推荐答案

将这些作品存储在字典或列表中。

解析在文本框中键入的字符串,并用平淡无奇的方式替换这些字符。



简单的Linq查询甚至是 string.Replace [ ^ ]可行。



对于更复杂的模式匹配,您可以查看 RegEx [ ^ ]替换。
Store these works in a dictionary or list.
Parse the string typed in the text box and replace any of these characters with a bland.

A simple Linq query or even a string.Replace[^] would work.

For more complex pattern matching you can look at a RegEx[^] replace.


这篇关于初学者需要帮助!!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆