1 2 3 4 5 6 7 8 9 10 11 | import re from django import template register = template.Library() @register.filter def replace ( string, args ): search = args.split(args[0])[1] replace = args.split(args[0])[2] return re.sub( search, replace, string ) |
1 2 3 4 5 6 7 8 9 10 11 | import re from django import template register = template.Library() @register.filter def replace ( string, args ): search = args.split(args[0])[1] replace = args.split(args[0])[2] return re.sub( search, replace, string ) |
Comments