Question

I want to show text on a web page without having to remember to go over it and check if there are any <'s and >'s in it, so simply copying the text from, say, notepad to visual studio isn’t good.

So I tried "paste alternate" but it adds line breaks, and keeps the original fonts etc. All I want is the text itself.

Is there an automatic way - via CSS or Visual Studio perhaps?

Was it helpful?

Solution

Regex search+replace: s/</&lt;/ and s/>/&gt;/

OTHER TIPS

Found an answer that uses jQuery.

Use the .text() function.

Will return all the text present in the HTML.

http://api.jquery.com/text/

For example ($('<p>test</p>').text());

will produce test

EDIT

For string substitution you can try the javascript replace method. Call it on document load. It should solve the problem

str.replace(">","&gt;");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top