ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Compare two strings and highlight changes using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="naresh1994"> naresh1994</a>,</p> <p>Refer below sample.</p> <p>Use regular expression and stringcollection check whether words are containing or not.</p> <p>Refer below sample for better understand.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:Label ID=&#34;lblMessage&#34; runat=&#34;server&#34; /&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Collections.Specialized;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Collections.Specialized</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { string message1 = &#34;Mr. Dhinna&#39;s broad international experience provides the board of directors with his unique insights related to Blockbuster strategy, operations and business&#34;; message1 += &#34;as a global company. Mr. Dhinna brings to the board significant commercial transaction experience from his Kissinger Associates role till 25/06/2016, as well as domestic and&#34;; message1 += &#34;international public policy experience. Mr. Dhinna has extensive knowledge in a number of important areas, including innovative problem-solving related to&#34;; message1 += &#34;global risks and opportunities, particularly with regard to China and Japan. He is also ex CFO of ABC Inc.&#34;; string message2 = &#34;Mr. Dhinna&#39;s broad international experience provides the board of directors with his unique insights related to Blockbuster strategy, operations and business&#34;; message2 += &#34;as a global company. Mr. Dhinna brings to the board significant commercials transaction less experience from his Kissinger Associates role till 25/06/2018, as well as domestic and&#34;; message2 += &#34;international public policy experience. Mr. Dhinna has extensive knowledge in a number of important areas, including innovative problem-solving could not be to&#34;; message2 += &#34;global risks and opportunities, particularly with regard to China and Japan. He is also ex CFO of ABC Inc.&#34;; StringCollection stringCollectionmessage1 = new StringCollection(); StringCollection stringCollectionmessage2 = new StringCollection(); stringCollectionmessage1.AddRange(System.Text.RegularExpressions.Regex.Split(message1, @&#34;\b(\w+)(\W){1,2}&#34;)); stringCollectionmessage2.AddRange(System.Text.RegularExpressions.Regex.Split(message2, @&#34;\b(\w+)(\W){1,2}&#34;)); for (int i = 0; i &lt; stringCollectionmessage1.Count; i++) { if (!stringCollectionmessage1.Contains(stringCollectionmessage2[i])) { lblMessage.Text += &#34;&lt;font color=&#39;Red&#39;&gt;&#34; + stringCollectionmessage2[i].ToString() + &#34;&lt;/font&gt;&#34; + &#34; &#34;; } else { lblMessage.Text += stringCollectionmessage1[i].ToString() + &#34; &#34;; } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)Handle Me.Load Dim message1 As String = &#34;Mr. Dhinna&#39;s broad international experience provides the board of directors with his unique insights related to Blockbuster strategy, operations and business&#34; message1 += &#34;as a global company. Mr. Dhinna brings to the board significant commercial transaction experience from his Kissinger Associates role till 25/06/2016, as well as domestic and&#34; message1 += &#34;international public policy experience. Mr. Dhinna has extensive knowledge in a number of important areas, including innovative problem-solving related to&#34; message1 += &#34;global risks and opportunities, particularly with regard to China and Japan. He is also ex CFO of ABC Inc.&#34; Dim message2 As String = &#34;Mr. Dhinna&#39;s broad international experience provides the board of directors with his unique insights related to Blockbuster strategy, operations and business&#34; message2 += &#34;as a global company. Mr. Dhinna brings to the board significant commercials transaction less experience from his Kissinger Associates role till 25/06/2018, as well as domestic and&#34; message2 += &#34;international public policy experience. Mr. Dhinna has extensive knowledge in a number of important areas, including innovative problem-solving could not be to&#34; message2 += &#34;global risks and opportunities, particularly with regard to China and Japan. He is also ex CFO of ABC Inc.&#34; Dim stringCollectionmessage1 As StringCollection = New StringCollection() Dim stringCollectionmessage2 As StringCollection = New StringCollection() stringCollectionmessage1.AddRange(System.Text.RegularExpressions.Regex.Split(message1, &#34;\b(\w+)(\W){1,2}&#34;)) stringCollectionmessage2.AddRange(System.Text.RegularExpressions.Regex.Split(message2, &#34;\b(\w+)(\W){1,2}&#34;)) For i As Integer = 0 To stringCollectionmessage1.Count - 1 If Not stringCollectionmessage1.Contains(stringCollectionmessage2(i)) Then lblMessage.Text += &#34;&lt;font color=&#39;Red&#39;&gt;&#34; &amp; stringCollectionmessage2(i).ToString() &amp; &#34;&lt;/font&gt;&#34; &amp; &#34; &#34; Else lblMessage.Text += stringCollectionmessage1(i).ToString() &amp; &#34; &#34; End If Next End Sub</pre> <p><span style="text-decoration: underline;"><strong>Output</strong></span></p> <p><span id="lblMessage">Mr Dhinna ' s broad international experience provides the board of directors with his unique insights related to Blockbuster strategy operations and businessas a global company Mr Dhinna brings to the board significant <font color="red">commercials</font> transaction <font color="red">less</font> from his Kissinger Associates role till 25 / 06 / 2016 <font color="red">2018</font> well as domestic andinternational public policy experience Mr Dhinna has extensive knowledge in a number of important areas including innovative problem - solving related <font color="red">could</font> <font color="red">not</font> <font color="red">be</font> opportunities particularly with regard to China and Japan He is also ex CFO of ABC Inc .</span></p>https://www.aspforums.net:443/Threads/198450/Compare-two-strings-and-highlight-changes-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/198450/Compare-two-strings-and-highlight-changes-using-C-and-VBNet-in-ASPNet/Wed, 24 Jul 2019 07:25:19 GMT