正则表达式应用

  • 提取句子中中英文数字

    u"([^\u4e00-\u9fa5\u0030-\u0039\u0041-\u005a\u0061-\u007a])"
    
    \u4e00-\u9fa5 汉字的unicode范围
    \u0030-\u0039 数字的unicode范围
    \u0041-\u005a 大写字母unicode范围
    \u0061-\u007a 小写字母unicode范围

    提取中文字符

    string_code = re.sub(u"([^\u4e00-\u9fa5])","",string)
    
posted @ 2019-08-27 16:44  FromZeroToOne  阅读(300)  评论(0编辑  收藏  举报