Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My requirement is to remove all the genuine HTML tags only from string in SQL Server. e.g.

my string could be
<P>This is a test Message</P> My salary is <$500 and i have to spent >Rs 899 <br/> Please suggest<font></Font>


My desired output should be
This is a test Message My salary is <$500 and i have to spent >Rs 899 Please suggest.
Posted
Comments
♥…ЯҠ…♥ 5-Feb-14 7:39am    
You sure you will always get <$500 and i have to spent > like this, $ symbol next to angle bracket?

1 solution

Hi Akhil,

You could refer this link[^], it will help you to remove the HTML tags from your string but you need customize more to get expected answer

If you want you can do it in C#, below is the code snippet you can make use of.
HTML
string htmlString = @"<P>This is a test Message</P> My salary is <$500 and i have to spent >Rs 899 <br/> Please suggest<font></Font>";
            string outputString = string.Empty;
            System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex(@"<[^>]\S*>");
            outputString = rx.Replace(htmlString, "");

String handling is always easy in C# when compared to SQL for most of them ;-)
So I recommend you to get the string from sql server and manipulate in C# (may be)

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v2
Comments
[no name] 5-Feb-14 7:47am    
Thanks RK, Yes I know customization is only solution still want to check if there any way to get rid all genuine HTML tags, also I need to do this in SQL Server only
♥…ЯҠ…♥ 5-Feb-14 7:52am    
Updated my solution, try that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900