日期:2014-05-17 浏览次数:20999 次
Regex expression_search = new Regex(textBox2.Text); //不知道括号里能否这样写?
Match m_Re = expression_search.Match(textBox1中的内容,逐行读取); //这里将textBox1逐行读取,求教如何实现textbox中的内容逐行读取?
if (m_Re.Success)
{
//匹配成功,将该符合的文字标红,但不知如何实现?
// XXXXXX
}
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int n = textBox2.Text.IndexOf(textBox1.Text, textBox2.SelectionStart + textBox2.SelectionLength);
if (n == -1)
n = textBox2.Text.IndexOf(textBox1.Text, 0);
if (n >= 0)
{
textBox2.SelectionStart = n;
textBox2.SelectionLength = textBox1.Text.Length;
ActiveControl = textBox2;
}
}
}
}