Click here to Skip to main content
15,072,691 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
i have this content
C#
<p style="font-style: normal; font-variant: normal; line-height: 18px;"><span style="line-height: 34px; font-family: Georgia; font-size: 16px;"><img alt="" src="/Portals/0/Blog%20Images/00aaelevatoredu%20(1024x717).jpg" style="width: 400px; height: 220px; float: left; margin: 5px;" />Whether math problems, an English paper, or a science fair project, more and more teachers are asking students to utilize technology based programs to complete assignments, and students and parents are oftentimes unprepared to meet the new academic requirements. Many times there is an assumption that because kids have grown up with technology, they will automatically know how to use a variety of software programs, but this is often not the case. Kids may be adept at playing video games, using a tablet or cell phone, and working on a computer, but may not have the proficiency in word processing, presentation programs, cloud storage and management, and organizational programs necessary to help them achieve academically. There are many software programs that are crucial for kids to be successful in early elementary school, into college and beyond.</span></p>


So here how can i remove html tags here
plz help me

What I have tried:

I have tried regex using javascript
Posted
Updated 21-Apr-16 19:53pm
Comments
F-ES Sitecore 21-Apr-16 8:11am
   
What regex did you use? If you google for how to strip html tags you'll find possible regex solutions to use.
   
Read it: What have you tried so far?
There is no such thing as "CSS tag".
—SA

Try this:

var content = "<p>Dear sms,</p><p>This is a test notification for push message from center II.</p>";

var text = $(content).text();


OR TRY this function:

function removeHTMLTags(){
	if(document.getElementById && document.getElementById("input-code")){
		var strInputCode = document.getElementById("input-code").innerHTML;
		/* 
			This line is optional, it replaces escaped brackets with real ones, 
			i.e. &lt; is replaced with < and &gt; is replaced with >
		*/	
		strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
			return (p1 == "lt")? "<" : ">";
		});
		var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
		alert("Input code:\n" + strInputCode + "\n\nOutput text:\n" + strTagStrippedText);	
	}	
}
   
try this


JavaScript
var input = 'your input string';
       var array = input.split('<')
       console.log(input);
       for (var i = 1; i < array.length; i++) {
           var temp = array[i].split('>')[0];
           input = input.replace(temp, '');
       }
       input = input.replace(/<>/g, '');  // output
       console.log(input);
   
v2
Try this:

var x ='<p style="font-style: normal; font-variant: normal; line-height: 18px;"><span style="line-height: 34px; font-family: Georgia; font-size: 16px;"><img alt="" src="/Portals/0/Blog%20Images/00aaelevatoredu%20(1024x717).jpg" style="width: 400px; height: 220px; float: left; margin: 5px;" />Whether math problems, an English paper, or a science fair project, more and more teachers are asking students to utilize technology based programs to complete assignments, and students and parents are oftentimes unprepared to meet the new academic requirements. Many times there is an assumption that because kids have grown up with technology, they will automatically know how to use a variety of software programs, but this is often not the case. Kids may be adept at playing video games, using a tablet or cell phone, and working on a computer, but may not have the proficiency in word processing, presentation programs, cloud storage and management, and organizational programs necessary to help them achieve academically. There are many software programs that are crucial for kids to be successful in early elementary school, into college and beyond.</span>'

var y =x.replace(/<[^>]*>/g, "")

JavaScript
console.log(y)


I tried in my system its working. Hope this will helpfull
   
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month