tags:

views:

51

answers:

2

I have an application that allows the user to create an article. The problem arises when the user pastes from something like Word which comes loaded with a bunch of markup.

I'm using a jQuery editor called tiny_mce which allows the markup. I do a htmlencode and decode obviously but it means that i carry a huge payload of markup.

Is there a way to strip (all) markup from pasted text and just keep the text?

Or is there a way that tiny_mce can show the markup as text?

A: 

Strip all HTML markup using Regex: http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx

string stripped = Regex.Replace(textBox1.Text,@"<(.|\n)*?>",string.Empty);

This Regex expression can be applied to the language of choice.

Riley
+1  A: 

It's been a while since I used tinyMCE, but when I did I used this paste plugin that did automatic clean-up on paste, including paste from Word.

Alconja
+1 Brilliant! Thanks @Alconja.
griegs