【发布时间】:2010-10-29 06:15:02
【问题描述】:
我希望完成以下工作,并想知道是否有人对如何最好地完成它有建议。
我有一个字符串,比如 'this-is,-toronto.-and-this-is,-boston',我想将所有出现的 ',-[az]' 转换为 ',-[AZ ]'。在这种情况下,转换的结果将是“this-is,-Toronto.-and-this-is,-Boston”。
我一直在尝试使用 re.sub(),但还没有弄清楚如何
testString = 'this-is,-toronto.-and-this-is,-boston'
re.sub(r',_([a-z])', r',_??', testString)
谢谢!
【问题讨论】:
标签: python