插入表单时如何删除Word标记废话? [英] How do I remove Word markup crap when inserting to a form?

查看:153
本文介绍了插入表单时如何删除Word标记废话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP构建CMS,而我的恐惧之一是用户将不得不从现有的Word(和Excel,但不要紧)文档中填充数据.现在,我已经看到了当他们不小心将它们从Word复制并粘贴到文本区域时会发生什么:数据库中充满了废话标记.

I'm building a CMS in PHP and one dread I have is that the users will have to fill the data in from existing Word (and Excel, but nevermind that) documents. Now, I've seen what happens when they carelessly copy and paste from Word to a textarea: the database got filled with crap markup.

现在,我当然可以自己剥离所有标记,但是我必须首先开始学习它.因此,我想问您:您是否测试了某些功能-常见的可疑插件(tinyMCE,FCKeditor等)在这里有帮助?最少侵入性解决方案的奖励.

Now, I could certainly strip all markup myself, but I'd have to start learning about it first. So I ask you: have you tested some functionality - plugins of the usual suspects (tinyMCE, FCKeditor, etc) that helps here? Bonus for the least intrusive solution.

推荐答案

不幸的是,我使用过的大多数HTML编辑器控件之一:

Sadly most of the HTML editor controls I've used either:

  1. 有一个按钮可以删除各种标记元素(单词,html,脚本等)
  2. 通过JavaScript在粘贴时去除全部标记.
  1. Have a button to strip out various elements of mark up (word, html, script, etc)
  2. Strip out all markup on paste via JavaScript.

如果将其保留在按钮上,那么通常来说,非技术用户会忘记按下它,因为他们不关心(有些人会说不必"):(

If you leave it to a button, then generally the non-technical users will forget to press it because they don't (some would say "shouldn't have to") care about it :(

通过使用正则表达式(现在您还有另一个问题;)),您可以执行类似于2的操作,但仅适用于xml字.

With a bit of playing around with Regular Expressions (now you have another problem ;)) you could do something similar to 2 but just for word xml.

这篇关于插入表单时如何删除Word标记废话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆