How to extract the substring between two markers?

前端 未结 18 2678
慢半拍i
慢半拍i 2020-11-22 06:02

Let\'s say I have a string \'gfgfdAAA1234ZZZuijjk\' and I want to extract just the \'1234\' part.

I only know what will be the few characte

18条回答
  •  感动是毒
    2020-11-22 06:10

    In python, extracting substring form string can be done using findall method in regular expression (re) module.

    >>> import re
    >>> s = 'gfgfdAAA1234ZZZuijjk'
    >>> ss = re.findall('AAA(.+)ZZZ', s)
    >>> print ss
    ['1234']
    

提交回复
热议问题