Python使用正则表达式拆分字符串

时间:2019-10-29 20:44:12

标签: python regex

我正在尝试使用正则表达式拆分此行:

Culture = [[Northmen]]|Title = Ceryse Hightower|Religion = [[Faith of the Seven|Faith of the Seven One]]|Title = Ceryse Hightower|Religion = [[Faith of the Seven|Faith of the Seven Two]]

我想在|内的所有[[]]上拆分它。

所以结果应该是一个字符串列表:

['Culture = [[Northmen]]', 'Title = Ceryse Hightower', 'Religion = [[Faith of the Seven|Faith of the Seven One]]', 'Title = Ceryse Hightower', 'Religion = [[Faith of the Seven|Faith of the Seven Two]]']

我知道如何简单地按|进行拆分,但是我不知道如何避免被|内部的[[]]进行拆分。

0 个答案:

没有答案