博客
关于我
【python】特定模式抽取字符串
阅读量:152 次
发布时间:2019-02-28

本文共 1625 字,大约阅读时间需要 5 分钟。

?????????????HTML????????????????Windows 7???Python 3.5.2??????????????

????<??>string<??>???????string???????????

import rep = re.compile(r'
(.*)
')matchp = p.search("
positive
")if matchp: print(matchp.group(1)) # ???? print(matchp.group(0)) # ?????

???????matchp.group(1) ???? "positive"?? matchp.group(0) ?????????

???????????


???????HTML????????????????????????

?????<??>string<??>???????string???????????

import rep = re.compile(r'
(.*)
')matchp = p.search("
positive
")if matchp: print(matchp.group(1)) # ???? print(matchp.group(0)) # ?????

???????matchp.group(1) ???? "positive"?? matchp.group(0) ?????????

???????????


?????

???????HTML???????????????????????????????????????????????????????

import rep = re.compile(r'
(.*)
')matchp = p.search("
positive
")if matchp: print(matchp.group(1)) # ???? print(matchp.group(0)) # ?????

?????

positive
positive

???

  • ??? matchp.group(1) ???? "positive"??????????????
  • ??? matchp.group(0) ????????????????????
  • ????????????????


    ?????

    ???????????????????????????????? .* ??????????????????????????HTML??????? <div> ???????????????????

    ????????????????

    import rep = re.compile(r'
    (.*?)
    ', re.DOTALL)matchp = p.search("
    positive
    ")if matchp: print(matchp.group(1)) # ??????????

    ????????? r'<polarity>(.*?)</polarity>' ??? re.DOTALL flag??? . ????????????????????????????????


    ???

    ??????????????????????????????????????????????????????

    转载地址:http://bszc.baihongyu.com/

    你可能感兴趣的文章
    Objective-C实现AvlTree树算法(附完整源码)
    查看>>
    Objective-C实现backtracking Jump Game回溯跳跃游戏算法(附完整源码)
    查看>>
    Objective-C实现BACKTRACKING 方法查找集合的幂集算法(附完整源码)
    查看>>
    Objective-C实现bailey borwein plouffe算法(附完整源码)
    查看>>
    Objective-C实现balanced parentheses平衡括号表达式算法(附完整源码)
    查看>>
    Objective-C实现base64加密和base64解密算法(附完整源码)
    查看>>
    Objective-C实现base64加解密(附完整源码)
    查看>>
    Objective-C实现base64编码 (附完整源码)
    查看>>
    Objective-C实现base85 编码算法(附完整源码)
    查看>>
    Objective-C实现basic graphs基本图算法(附完整源码)
    查看>>
    Objective-C实现BCC校验计算(附完整源码)
    查看>>
    Objective-C实现bead sort珠排序算法(附完整源码)
    查看>>
    Objective-C实现BeadSort珠排序算法(附完整源码)
    查看>>
    Objective-C实现bellman ford贝尔曼福特算法(附完整源码)
    查看>>
    Objective-C实现bellman-ford贝尔曼-福特算法(附完整源码)
    查看>>
    Objective-C实现bellman-ford贝尔曼-福特算法(附完整源码)
    查看>>
    Objective-C实现bellmanFord贝尔曼-福特算法(附完整源码)
    查看>>
    Objective-C实现BellmanFord贝尔曼-福特算法(附完整源码)
    查看>>
    Objective-C实现bezier curve贝塞尔曲线算法(附完整源码)
    查看>>
    Objective-C实现bfs 最短路径算法(附完整源码)
    查看>>