Skip to content

Instantly share code, notes, and snippets.

Avatar

Damon jinstrive

  • QF technology
View GitHub Profile
@jinstrive
jinstrive / replace_matched_part.py
Created Oct 22, 2015
python string operate, replace string in Regular Expression.
View replace_matched_part.py
def replace_matched_part(pattern, lstring, repl_str, group_name):
"""
:param pattern: 类似 '.*?_(?P<char>\w)_\d\.\w+$'
:param lstring: 需要替换的字符串
:param repl_str: 匹配部分替换成的字符串
:param group_name: 匹配中的组名 char
:return:
"""
def _rep_func(m):
return ''.join([m.string[:m.start(group_name)], repl_str, m.string[m.end(group_name):]])
@jinstrive
jinstrive / remove_emoji.py
Created Oct 22, 2015
python remove emoji in string
View remove_emoji.py
def remove_emoji(data):
"""
去除表情
:param data:
:return:
"""
if not data:
return data
if not isinstance(data, basestring):
return data
View remove_html_tag.py
from HTMLParser import HTMLParser
def remove_html_tags(html):
"""
移除html 标签类 方法
"""
if not html:
return html
if not isinstance(html, basestring):
return html