2016-09-28 8 views

答えて

0

一つの呼び出しが唯一の非重複マッチを処理します。

その周りの一つの方法は強引です:

>>> s = 'apple < < orange' 
>>> old = None 
>>> while s != old: 
... old = s 
... s = re.sub(r'(apple.*)<(.*orange)', r'\1-\2', s) 
... 
>>> print s 
apple - - orange 
関連する問題