-------

-------

  • NA
  • 213
  • 6.3k

get the new word from the second string

Oct 5 2020 8:05 AM
I am trying to get the new words from the second string when match the same word(second string) from another string(first string)
 
Current output is:
 
Insert Word Is: matching hims by website
 
I want to:
 
Insert Word Is: by website
 
.cs
  1. protected void Button1_Click(object sender, EventArgs e)    
  2. {    
  3.     if (IsPostBack)    
  4.     {    
  5.         Label3.Text = "";    
  6.     }    
  7.        
  8.     var result1 = stextbox.Text.Split(new char[] { ' ' }).Except(ftextbox.Text.Split(new char[] { ' ' })).ToArray();    
  9.     int count = 0;    
  10.     count = result1.Length;    
  11.   
  12.     //string lastWord = result1[result1.Length - 1];    
  13.   
  14.     for (int i = 0; i < count; i++)    
  15.     {    
  16.         Label3.Text += result1[i].ToString() + "   ";    
  17.     }    
  18.   
  19.     Label3.Text = "Insert Word Is: " + Label3.Text;    
  20.      
  21.     //below code is get the last word    
  22.    //var result1 = stextbox.Text.Split(new char[] { ' ' }).Except(ftextbox.Text.Split(new char[] { ' ' })).ToArray();    
  23.     //int count = 0;    
  24.     //count = result1.Length;    
  25.   
  26.     //string phrase = ftextbox.Text;    
  27.     //string subPhrase = stextbox.Text;    
  28.     //subPhrase = phrase;    
  29.     //string temp;    
  30.     //while (true)    
  31.     //{    
  32.     //    temp = subPhrase.Substring(1 + subPhrase.IndexOf(" "));    
  33.     //    if (temp.Equals(subPhrase))    
  34.     //    {    
  35.     //        break;    
  36.   
  37.   
  38.     //    }    
  39.     //    else    
  40.     //    {    
  41.     //        subPhrase = temp;    
  42.     //    }    
  43.     //}    
  44.   
  45.     //Label3.Text = "Insert Word Is: " + temp;   
.aspx
  1. <asp:TextBox ID="ftextbox" runat="server" TextMode="MultiLine" Width="500px" Height="200px"></asp:TextBox>    
  2. <asp:TextBox ID="stextbox" runat="server" TextMode="MultiLine" Width="500px" Height="200px"></asp:TextBox>  
  3. <br /><br />  
  4. <asp:Button ID="Button1" runat="server" Text="Compare" OnClick="Button1_Click" />  
  5. <br />  
need help

Answers (8)