djangosnippets.org: Latest snippets tagged with 'replace'https://djangosnippets.org/tags/replace/2017-01-25T01:52:31.834463-06:00replace
2017-01-25T01:52:31.834463-06:00atombrellahttps://djangosnippets.org/snippets/10602/<p>Small example of how to write your own function. This is not available in Django. The function just replaces static text strings, regular expressions are not supported.</p>
<p>The syntax is the same in SQLite, PostgreSQL, MySQL and Oracle.</p>
Freely redistributablePython-like string interpolation in Javascript
2010-06-20T09:04:49.088575-05:00phxxhttps://djangosnippets.org/snippets/2074/<p>Provides python-like string interpolation.
It supports value interpolation either by keys of a dictionary or
by index of an array.</p>
<p>Examples:</p>
<pre><code> interpolate("Hello %s.", ["World"]) == "Hello World."
interpolate("Hello %(name)s.", {name: "World"}) == "Hello World."
interpolate("Hello %%.", {name: "World"}) == "Hello %."
</code></pre>
<p>This version doesn't do any type checks and doesn't …</p>
Freely redistributable