RE split multiple arguments | (or) returns none python

后端 未结 3 1486
南旧
南旧 2021-02-15 12:35

I\'m using the RE expression in python and trying to split a chunk of text by period and by exclamation mark. However when I split it, I get a \"None\" in the result

<         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-15 13:30

    Here's a simpler expression (any period not followed or preceeded by a period) with the outer capturing group around the whole or | clause to avoid the None, not just the first part:

    re.split(r'((?

提交回复
热议问题