随笔: Python日志解析-正则表达式

随笔: Python日志解析-正则表达式

# 日志解析
class Log_parse(object):
    '''
    正则表达式
    '''
    def regular_expression(self, file, start_value, end_value):
        text = re.sub('s+', '', file)
        pattern = start_value+'(.*?)'+end_value
        match = re.search(pattern, text)
        return match.group(1)

原文地址:https://www.cnblogs.com/caodingzheng/p/14007079.html