0
Python不断返回一个带有破碎字符的字符串。python re.sub正则表达式
蟒蛇
test = re.sub('handle(.*?)', '<verse osisID="lol">\1</verse>', 'handle a bunch of random text here.')
print test
我想
<verse osisID="lol">a bunch of random text here.</verse>
什么我得到
<verse osisID="lol">*broken character*</verse>a bunch of random text here.
你是一个美丽的人:) – user1442957 2012-08-09 19:48:28
你可能想后的空间匹配'处理“,但在下一个单词之前,因为这会阻止'...> br ...'你可以用'handle *(。*)'来做这个假定你只有空格(不是其他空格) – 2012-08-09 19:51:16
@AndrewCox:我会用'\ s *'来匹配那里的空白,为什么只限于空间? – 2012-08-09 19:54:14