Search about text

Posted by anwarbesa-15403 under C# category on | Points: 40 | Views : 1007
Hi.. this is a code written in for searching about text from a string

There are four text boxes one for entering a string or text from the user, another for the label addressed as (start with), another for the label addressed as (end with).. and the last one for the result.(Note:you should make the property of text box as multi line)

And there is a button for search.. and now you should click the button and write this code:

string[] sentences = textBox1.Text.Split(' ');
string sPattern1 = textBox2.Text.Trim();
string sPattern2 = textBox3.Text.Trim();
textBox4.Text = "";
foreach (string s in sentences)
if (sPattern1.Trim().Length > 0 && s.ToUpper().StartsWith(sPattern1.ToUpper()))

textBox4.Text += s + "\r\n";
if (sPattern2.Trim().Length > 0 && s.ToUpper().EndsWith(sPattern2.ToUpper()))

textBox4.Text += s + "\r\n";

I wish this is will be helpful ^_^

Thanks and regards

Comments or Responses

Login to post response