Replacing : with "${" at the beginning of the word and adding "}" at the end of the word

zljubisic at gmail.com zljubisic at gmail.com
Tue Oct 2 08:33:47 EDT 2018


Hi,

if I have a string:

sql = """
where 1 = 1
and field = :value 
and field2 in (:list)
"""

I would like to replace every word that starts with ":" in the following way:
1. replace ":" with "${"
2. at the end of the word add "}"


An example should look like this:

where 1 = 1
and field = ${value}
and field2 in (${list})

How to do that?

Regards.



More information about the Python-list mailing list