fork(2) download
  1. import re
  2. text = r"<img src='foobar.jpg'>"
  3. my_regex_pattern = r"""((?<=src=["'])|(?<=href=.))(?!(http(s|)(:|%3[Aa])))([0-9A-Za-z%?&#_=+./~])*(?=['"])"""
  4. prefix = r"http://e...content-available-to-author-only...e.com/bar/"
  5. res = re.sub(my_regex_pattern, prefix.replace('\\', '\\\\') + r'\g<0>', text)
  6. print(res)
Success #stdin #stdout 0.02s 9576KB
stdin
Standard input is empty
stdout
<img src='http://e...content-available-to-author-only...e.com/bar/foobar.jpg'>