Advertisement
bAngelov

Pycharm django search-replace patterns

Oct 2nd, 2024 (edited)
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Pycharm django template replace patterns:
  2.  
  3. Anchor tag search-replace patterns:
  4. search:
  5.     href="/static/(?<url>.*)"
  6. replace:
  7.     href="\{\% static '${url}' \%\}"
  8.  
  9. Image tag search-replace pattern:
  10. search:
  11.     src="/static/(?<url>.*)"
  12. replace:
  13.     src="\{\% static '${url}' \%\}"
  14.  
  15. UPDATE: pattern encompassing both:
  16. search:
  17.     (?<type>href\s*=|src\s*=)\s*(?<quote>[\"\']).*static/(?<url>[^'"]*)\k<quote>
  18. replace:
  19.     ${type}"\{\% static '${url}' \%\}"
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement