سؤال

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?

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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;");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top