fork download
  1. import re
  2.  
  3. s = "htmlhtl {% static path1 %} htmlhtml {% static path2/path3 %} htmlhtml "
  4. rx = re.compile(r'{% static (?P<path>\S+) %}')
  5.  
  6. s = rx.sub(r'www.static.com/\g<path>', s)
  7. print(s)
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
htmlhtl www.static.com/path1 htmlhtml www.static.com/path2/path3 htmlhtml