简体   繁体   English

summernote编辑器如何将流星存储在mongodb中

[英]how summernote editor storing the in mongodb with meteor

I am able to store in the mongodb in html format like this: 我能够将html格式存储在mongodb中,如下所示:

{
    "_id" : "GwgCygRMgsB8jRBFr",
    "html" : "<p>mid</p><ol><li><b>m</b></li><li>,mbgb</li><li>lgkbg</li><li>b,g</li></ol><p><br></p><p><br></p>"
}
{
    "_id" : "XyK5jaLgQNxJyDP4u",
    "html" : "<p>mid</p><ol><li><b>m</b></li><li>,mbgb</li><li>lgkbg</li><li>b,g</li></ol><p><br></p><p><br></p>"
}

I want to store only a text edit in the textarea not the elements of he html how i need to send only the text can anybody help ,I am trying this since form two two days I am new to meteor . 我只想在textarea中存储一个文本编辑,而不是他的html元素,我只需要发送文本就可以帮助任何人,我正在尝试这样做,因为两天后我才是流星。

Before storing it in the database you can filter the text using regular expressions. 在将其存储在数据库中之前,您可以使用正则表达式过滤文本。 But they aren't accurate 100% of time. 但是它们并不是100%准确的时间。

var htmlString = "<div><p>Paragraph 1 text</p><p>Paragraph 2 text</div>";

var regEx = /(<([^>]+)>)/ig;

htmlString.replace(regEx, " "); //this will replace you html tags with space

output would be "Paragraph 1 text Paragraph 2 text" 输出将是“第1段文字第2段文字”

You can test you regular expression like below 您可以如下测试正则表达式

var isValid = /(<([^>]+)>)/ig.test("<p>Some text</p>");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM