2018-11-16から1日間の記事一覧

Python の文字列ハイライト機能

サジェストのハイライト機能をPython側で実装 import re # 前方一致 def hilight_apply_pre(word, _list): return [re.sub('^{}'.format(re.escape(word)), '<{0}>{1}</{0}>'.format('em', word), l, 1) for l in _list] # 部分一致 def hilight_apply_sub(word, _…