Quick actions

cmd+k|ctrl+k

Navigation

Languages

re.sub

Snippet info

Language

Python

Visibility

public

Author

pheker

Created

2018-01-30T10:07:22Z

Updated

2018-01-31T05:53:27Z

print("Hello World!")

import re

# relative to absolute
strs = '<img id="img_zhaoliying" src="img/zhangliying.png" title="赵丽颖"/>';
ret = re.sub(r'(?P<img><img[^>]+?src=")',"\g<img>http://www.baidu.com/",strs); #count,flags
print(ret)

# add preffix
ret = re.sub(r'(?P<img><img[^>]+?)src',"\g<img>data-src",strs); #count,flags
print(ret)
INFO