| Microsoft | Articles | Forums | FAQs |
| C# .NET |  |  |  |  |
| VB.NET |  |  |  |  |
| Visual Studio .NET |  |  |  |  |
| ADO.NET |  |  |  |  |
| Xml / Xslt |  |  |  |  |
| VB 6.0 |  |  |  |  |
| .NET CF |  |  |  |  |
| GDI+ |  |  |  |  |
| LINQ |  |  |  |  |
| Deployment |  |  |  |  |
| Security |  |  |  |  |
| FoxPro |  |  |  |  |
| Silverlight / WPF |  |  |  |  |
| Entity Framework |  |  |  |  |
| RIA Services |  |  |  |  |
|
| Web | Articles | Forums | FAQs |
| JavaScript |  |  |  |  |
| ASP |  |  |  |  |
| ASP.NET |  |  |  |  |
| WCF |  |  |  |  |
|
| Databases | Articles | Forums | FAQs |
| SQL Server |  |  |  |  |
| Access |  |  |  |  |
| Oracle |  |  |  |  |
| MySQL |  |  |  |  |
| Other Databases |  |  |  |  |
|
| Office | Articles | Forums | FAQs |
| Excel |  |  |  |  |
| Word |  |  |  |  |
| Powerpoint |  |  |  |  |
| Outlook |  |  |  |  |
| Publisher |  |  |  |  |
| Money |  |  |  |  |
|
| Non-Microsoft | Articles | Forums | FAQs |
| NHibernate |  |  |  |  |
| Perl |  |  |  |  |
| PHP |  |  |  |  |
| Ruby |  |  |  |  |
| Java |  |  |  |  |
| Linux / Unix |  |  |  |  |
| Apple |  |  |  |  |
| Open Source |  |  |  |  |
|
| Operating Sys | Articles | Forums | FAQs |
| Windows 7 |  |  |  |  |
| Windows Server |  |  |  |  |
| Windows Vista |  |  |  |  |
| Windows XP |  |  |  |  |
| Windows Update |  |  |  |  |
| MAC |  |  |  |  |
| Linux / UNIX |  |  |  |  |
|
| Server Platforms | Articles | Forums | FAQs |
 |  |  |  |  |
| BizTalk |  |  |  |  |
| Site Server |  |  |  |  |
| Exhange Server |  |  |  |  |
| IIS |  |  |  |  |
|
| Graphic Design | Articles | Forums | FAQs |
| Macromedia Flash |  |  |  |  |
| Adobe PhotoShop |  |  |  |  |
| Expression Blend |  |  |  |  |
| Expression Design |  |  |  |  |
| Expression Web |  |  |  |  |
|
| Other | Articles | Forums | FAQs |
| Lounge |  |  |  |  |
| Subversion / CVS |  |  |  |  |
| Ask Dr. Dotnetsky |  |  |  |  |
| Active Directory |  |  |  |  |
| Networking |  |  |  |  |
| Uninstall Virus |  |  |  |  |
| Job Openings |  |  |  |  |
| Product Reviews |  |  |  |  |
| Search Engines |  |  |  |  |
| Resumes |  |  |  |  |
|
| |
|
|
| Find and Replace in HTML Text |
| Prachi AAAA posted at Saturday, November 07, 2009 6: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.
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|
| Find and Replace in HTML Text |
mv ark provided a rated reply to Prachi AAAA on Saturday, November 07, 2009 7:21 AM |
|
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 |
| Reply Reply Using Power Editor |
| M.V. 'Anil' Radhakrishna is a seasoned developer and a Microsoft MVP (ASP/ASP.NET). He blogs his little discoveries and Web development tips, tricks and trivia quite regularly. You can find some of his unusual code samples & snippets at his Code Gallery. |
| |
Rank |
Winnings |
Points |
| November |
6 |
$46.00 |
119 |
| October |
4 |
$66.00 |
225 |
|
|
|
|
|
|
| Find and Replace in HTML Text |
| Prachi AAAA replied to mv ark on Saturday, November 07, 2009 7:49 AM |
|
But after replacing I want to keep formaating if done on any other word then How can I do this? |
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| re |
Web star provided a rated reply to Prachi AAAA on Saturday, November 07, 2009 10:49 AM |
|
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
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
5 |
$55.00 |
143 |
| October |
10 |
$28.00 |
94 |
|
|
|
|
|
|
|
|
| Find and replace in HTML TEXT |
| Prachi AAAA replied to F Cali on Sunday, November 08, 2009 12:20 AM |
|
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.
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| Replace |
F Cali provided a rated reply to Prachi AAAA on Sunday, November 08, 2009 12:29 AM |
|
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, SQL Server Helper
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
3 |
$65.00 |
168 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| About HTML text |
| Prachi AAAA replied to F Cali on Tuesday, November 10, 2009 5:14 AM |
|
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?
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|
|
|
|