Click here to Skip to main content
15,672,088 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre lang="HTML">
Hello CodeProjecters,

first of all, i'm going to say thanks because you have taking the time to take a look at my question.

here is my question, how do i remove the string and the tags together that inside "<>", it's just simple HTML tags,

i've tried using regex pattern like this : <.*?> and it also wont work, if the style is like this : <!--if [end if] --> or < m:blabla xmlns:m="#unknown" /> or < div id="divclass" >

many thanks to the one that have post an answer here.
Updated 5-Nov-14 4:14am
DamithSL 5-Nov-14 10:14am    
can you add sample inputs and expected outputs?
Andrew Budiman 5-Nov-14 10:16am    
input simple is : "<!--[if gte mso 9]><xml> <o:officedocumentsettings> <o:allowpng> </xml><![endif]--><br /><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal <w:zoom>0 <w:trackmoves> <w:trackformatting> <w:punctuationkerning> <w:validateagainstschemas> <w:saveifxmlinvalid>false <w:ignoremixedcontent>false <w:alwaysshowplaceholdertext>false <w:donotpromoteqf> <w:lidthemeother>EN-US <w:lidthemeasian>X-NONE <w:lidthemecomplexscript>X-NONE <w:compatibility> <w:breakwrappedtables> <w:snaptogridincell> <w:wraptextwithpunct> <w:useasianbreakrules> <w:dontgrowautofit> <w:splitpgbreakandparamark> <w:enableopentypekerning> <w:dontflipmirrorindents> <w:overridetablestylehps> <m:mathpr> <m:mathfont m:val="Cambria Math"> <m:brkbin m:val="before"> <m:brkbinsub m:val="--"> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> example bla bla bla bla bla......"

and the output i want to get it is : "example bla bla bla bla bla......"

try with
String res= Regex.Replace(htmlInput, @"<[^>]*>", String.Empty);


if you want to remove both <> and {} use @"<[^>]*>|{[^>]*}"
Share this answer
Andrew Budiman 5-Nov-14 10:41am    
and i've forgot 1 thing, the tags is also inclued <>{} this, the example is <!-- end if-->{modmso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt}<!-- end if --> example bla bla bla bla.....

and i want the input : example bla bla bla bla.....
DamithSL 5-Nov-14 10:53am    
change the regex to @"<[^>]*>|{[^>]*}"
Andrew Budiman 10-Nov-14 0:57am    
thanks before sir, i have solved the problem that cause with html tag,
and now there's some problem coming out, and i wanna discard the word, here is the example :
Normal 0 false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable ADHI is the best program..

i want just to take the word ADHI is the best program, and the other was discarded.

You could also use my StringParser[^] class to do this for you.

Share this answer
Something like this?
Remove all the HTML tags and display a plain text only inside (in case XML is not well formed)[^]

Be sure to look at the original Tip and the other alternatives.
Share this answer

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