From b389560aed50c5322937da59fd43bd2cdcb6ea06 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 21 Sep 2019 18:58:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/searchs/index.json.jbuilder | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder index 27674e894..be62bf865 100644 --- a/app/views/searchs/index.json.jbuilder +++ b/app/views/searchs/index.json.jbuilder @@ -10,10 +10,12 @@ json.results do # 去除开头标点符号 reg = /^[,。?:;‘’!“”—……、]/ # 附件的替换 - atta_reg = /!\[]\(\/api\/attachments\/\d+\)/ - highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '') + atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/ + highlights[:description]&.first&.sub!(reg, '') + highlights[:description]&.map{|des| des.gsub!(atta_reg, '')} Rails.logger.info("#########serach_description#{highlights[:description]}------------#{highlights[:description]&.first}") - highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '') + highlights[:content]&.first&.sub!(reg, '') + highlights[:content]&.map{|des| des.gsub!(atta_reg, '')} json.content highlights end