print re.sub("\((I+|i+|[a-z0-9])\)","\n\g<0>",buff)
発生します
The Integrated Programme Framework of the ISSSS has been established to:
(a) create a protective environment for civilians by strengthening the security forces, and improving discipline and control;
(b) support the demobilization and reintegration of armed groups;
(c) re-establish state functions in areas formerly controlled by armed groups, through the training and deployment of state officials (police, penitentiary, judicial and administration) to uphold the rule of law and public order,
(d) ensure open road access and infrastructure;
(e) promote a safe and dignified return of internally displaced persons and refugees; and
(f) address priority social needs and key sources of conflict and initiate economic recovery.
「再確立」などのハイフンでつながれた単語の問題に遭遇したという理由だけで、完全に「普遍的な」ものを作成することに私は懐疑的です。上記の正規表現は大部分のケースをカバーするはずであり、「|」内のものを追加または削除することで簡単に調整できるはずです オペレーター。そうは言っても、もう少し遊んでテスト文を追加したところ、十分に機能しました。「)」、「.」、または「-」が使用されているなどの潜在的な問題を回避するために、スペースから始めたと仮定する必要がありました。
>>> buff += "This is a) test of i) one ii) two iii) three a. four and b- five"
>>> print re.sub(" \({0,1}(I+|i+|[a-zA-Z0-9])(\)|\.|-)","\n\g<0>",buff)
The Integrated Programme Framework of the ISSSS has been established to:
(a) create a protective environment for civilians by strengthening the security forces, and improving discipline and control;
(b) support the demobilization and reintegration of armed groups;
(c) re-establish state functions in areas formerly controlled by armed groups, through the training and deployment of state officials (police, penitentiary, judicial and administration) to uphold the rule of law and public order,
(d) ensure open road access and infrastructure;
(e) promote a safe and dignified return of internally displaced persons and refugees; and
(f) address priority social needs and key sources of conflict and initiate economic recovery.This is
a) test of
i) one
ii) two
iii) three
a. four and
b- five