【问题标题】:Python: Find Surrounding parts of a string with irrelevant section in the middlePython:查找中间不相关部分的字符串的周围部分
【发布时间】:2013-05-29 00:57:02
【问题描述】:

所以我有一个包含几个类似内容的大字符串。我想找到一个字符串的一部分,但它的一部分是无关紧要的。

例如: “0” 废话“11” “0” 废话“3” “0” 废话“6” “0” 废话“600” “0”

我想找到'blah'...' 其中'...'是数字,我可以得到'...'的值

有没有简单的方法可以做到这一点?

【问题讨论】:

    标签: python string find partial surround


    【解决方案1】:
    >>> import re
    >>> re.findall(r'blah"(\d+)"','"0" blah"11" "0" blah"3" "0" blah"6" "0" blah"600" "0"')
    ['11', '3', '6', '600']
    

    【讨论】:

      猜你喜欢
      • 2016-02-24
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 1970-01-01
      相关资源
      最近更新 更多