VB.NET - Find and Replace in HTML Text
Asked By Soft DEveloper
07-Nov-09 06:04 AM
Hello,
I have HTML Text along with HTML tags.I want to find a particular word and replace it with other
Problem is if HTML Text contains text as "Cold,<strong>Cough</strong>,Fever,Para"
And if i want to remove "Cough," then comma(,) is after strong closing tag (</strong>).
As in above case i have made Cough bold, user can do any HTML formatting so how can I remove particular
word with comma.
Find and Replace in HTML Text
Use the line below to remove any HTML tags from the content -
string strippedText = System.Text.RegularExpressions.Regex.Replace(text,@"<(.|\n)*?>",string.Empty);
You can then find & replace the required word from the variable strippedText
Find and Replace in HTML Text
But after replacing I want to keep formaating if done on any other word then How can I do this?
re
whats problem if u wna to replace any word with comma(,)
string strippedText = System.Text.RegularExpressions.Regex.Replace("Cough",",");
rest format will be same where user done
Highlight Text Using Javascript
If I understand your requirement correctly and based on your example, you want to highlight certain words in your HTML page. This is similar to what other web pages do when they are found from a search engine like google. If this is the case, the following links may be able to help you do just that:
http://www.eggheadcafe.com/articles/highlight_google_keywords.asp
http://eriwen.com/javascript/highlight-search-results-with-js/
Regards,
http://www.sql-server-helper.com/sql-server-2008/import-export-unknown-column-type-geography-geometry.aspx
Find and replace in HTML TEXT
Hello,
I have HTML Editor in my Windows application in which user can type and fomat their text such as they can make their text bold,Change Font,Text Color etc.I also have a grid in which User can select from the grid.
Whenever User selects record from the grid,the text from grid is added in my HTML Editor appending text with comma. i.e if User selects Cough and Cold from grid the text displayed in HTML Editor is
Cough,Cold.
Now after adding this text user can do various formatting as described above.
If the User makes "Cough" word BOLD then I have value as <strong>Cough</strong>,Cold.
Now if User deselects the cough row from grid it should be removed from HTMLEditor So now how can I find "Cough," so that the string remaining in HTML Editor is only "Cold" and not ",Cold"
and in my database I have stored text along with HTML tags.
Replace
One option you can do is to continue with your replacing of the string without the comma. Then follow that replace with another replace and check if the remaining string starts with a comma and if it does, then remove that extra comma. If the text that was replaced is in the middle of the selection, then look for two consecutive commas and replace it with a single comma.
So for case #1, "<strong>Cough</strong>,Cold" becomes ",Cold". Since it starts with a comma, replace that first comma with an empty string.
And for case #2, "Flu,<strong>Cough</strong>,Cold" becomes "Flu,,Cold". Since there's 2 commas together, replace that with a single-comma.
Hope this helps.
Regards,
http://www.sql-server-helper.com/sql-server-2008/import-export-unknown-column-type-geography-geometry.aspx
About HTML text
Case 2nd which you have told will not contain string as "Flu,,Cold" but the bold tag which was formatted for "Fever" will also be present in that string i.e the string will be "Flu,<stromg></strong>,Cold.
So how to parser and write generic code for a string which contains textalong with tags an d replace it?

Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B)What is a types? (B) What is concept of Boxing and Unboxing ? (B) What is the difference between VB.NET and C#? (I) what is the difference between System exceptions and Application exceptions? (I)What objects in Remoting? (A) What are the ways in which client can create object on server in CAO model? (A) Are CAO stateful in nature? (A) To create objects in CAO page ? (I) Can we post and access view state in another application? (I) What is SQL Cache Dependency in ASP.NET 2.0? (I) How do we enable SQL Cache Dependency in ASP.NET 2.0? (I) What is Post Cache substitution? (I) Why are different properties provided by Object-oriented systems? (B) How can we achieve inheritance in VB.NET? (I) what are abstract classes? (B) What is a Interface? (A) What is difference
SEO. I am basically a C# developer and I have little knowledge of web page (html) "designing". Thanks in advance. it need optimization optimize yr code optimize yr database query optimize connection , pooling etc Site speed factors What affects site loading speed? Let's see: • web server speed (server resources, Internet connection speed) • database usage (none, one or many) • HTML code page size (20kb or larger) • CSS file size (5kb or larger) • Total image size larger) • Javascript and other script usage (none, 10kb or larger) • amount of file requests (stylesheets, Server Side Includes, images, scripts, etc) Alright, but what do you do with all that? Web server speed Web server can affect your site speed in several cases: when there are many sites on the server and it is running slow or it is hosted on a narrow Internet connection. To
visual basic what r the vb .net features?. . . . . . . . . . . . . . . . . . Visual Basic .NET provides the easiest, most productive language and tool for rapidly building NET comes with features such as a powerful new forms designer, an in-place menu editor, and automatic control anchoring and docking. Visual Basic .NET delivers new productivity features for building and write code to respond to events. Visual Basic .NET 2003 comes with an enhanced HTML Editor for working with complex Web pages. We can also use IntelliSense technology and tag completion, or choose the WYSIWYG editor for visual authoring of interactive Web applications. Simplified Deployment With Visual Basic .NET we can binding scenarios. Using ADO.NET, Visual Basic .NET can gain high-speed access to MS SQL Server, Oracle, DB2, Microsoft Access, and more. Improved Coding You can code faster and more effectively
call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Dim pagedData As New PagedDataSource Private Sub Page_Load(ByVal sender CurrentPageIndex = 0 End Try ' btnPrev.Visible = (Not pagedData.IsFirstPage) ' btnNext.Visible = (Not pagedData.IsLastPage) pageNumber.Text = (pagedData.CurrentPageIndex + 1) & " of " & pagedData.PageCount theDataList.DataSource = pagedData theDataList.DataBind() End Sub Private Sub Sub End Class = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = < %@ Page Language = "vb" AutoEventWireup = "false" Codebehind = "PagingDS.aspx.vb" Inherits = "DC.Paging"%> < HTML> <HEAD> <title> Paging with ASP.NET - DataSet Example - VB.NET< / title> <META http-equiv = "Content-Type" content = "text / html; charset = iso-8859-1"> < / HEAD> <body> <form runat = "server" ID = "Form1"> <font size = "-1" face = "Verdana, Arial, Helvetica, sans-serif"> <asp:label id = "pageNumber
source code for exporting to .pdf, .doc, . . . and printing crystal reports in vb.net end of post u can export and print. Imports CrystalDecisions. Shared Imports System.IO Public call is required by the Web Form Designer ' Do not modify it using the code editor. InitializeComponent() ' this is the most IMPORTANT line of code ' if this line is not writen the ' " LOGON FAILED" error starts displaying crReportDocument.SetDatabaseLogon( " username" , _ " password" , " sql-server" , " database" ) ' the Above line works even if only username ' and password is supplied as below crReportDocument.SetDatabaseLogon("username", _ " password" ) ' , "sql-server", "database") ' this will hide the group tree CrystalReportViewer1.DisplayGroupTree = False CrystalReportViewer1.ReportSource = crReportDocument ' IF REPORT your Report Will Be displayed ' now Without Logon Failed Error With DropDownList1.Items .Add( " Rich Text (RTF)" ) .Add( " Portable Document (PDF)" ) .Add( " MS Word (DOC)" ) .Add( " MS Excel (XLS)" ) End With