清理大块纯文本 - 查找并替换纯文本

时间:2015-07-09 21:45:55

标签: jquery

我有大量文本(数千行)需要清理一下。我有2个值,“日期”和“标题”。目前,“标题”包含句子和数字。号码以“否”开头。并有日期加上几个随机字符。我想要“约会”,“标题”和“不”。 “标题”将不再包含“no.xxxxx”字符。

所以文本目前看起来像这样:

"date": "02/01/2012",
"title": "my sample title no. 02012012-abc",

"date": "02/01/2012",
"title": "my sample title is always different and varies in character length    no. 02012012-cde",

"date": "02/01/2012",
"title": "my sample title is always different and varies in character length    no. 02012012-ghe",

"date": "02/01/2012",
"title": "my sample title is always different and varies in character length    no. 02012012-zxa"

我想清理数据,如下所示:

"date": "02/01/2012",
"title": "my sample title",
"no.": "02012012-abc",

"date": "02/01/2012",
"title": "my sample title is always different and varies in character length",
"no.": "02012012-cde",

"date": "02/01/2012",
"title": "my sample title is always different and varies in character length",
"no.": "02012012-ghe",

"date": "02/01/2012",
"title": "my sample title is always different and varies in character length",
"no.": "02012012-zxa"

1 个答案:

答案 0 :(得分:2)

您可以使用正则表达式将/no./g替换为\nno.