Python regex: splitting on pattern match that is an empty string

前端 未结 2 590
情书的邮戳
情书的邮戳 2020-11-28 14:34

With the re module, it seems that I am unable to split on pattern matches that are empty strings:

>>> re.split(r\'(?

        
2条回答
  •  无人及你
    2020-11-28 15:05

    import regex
    x="bazbarbarfoobar"
    print regex.split(r"(?

    You can use regex module here for this.

    or

    (.+?(?

    Use re.findall .

    See demo

提交回复
热议问题