ようにするだろう最も簡単な方法データベースはすべての作業を行います。
connection.execute(%q{
update your_table
set your_column = replace(
replace(
your_column,
'<img src="/images/emoticons/happy.png">',
':)'
),
'[img]/images/emoticons/happy.png[/img]',
':)'
)
})
ソースまたはターゲット文字列に引用符が含まれている場合(またはwr手でそれらをiting)、使用してconnection.quote
:
from1 = connection.quote('<img src="/images/emoticons/happy.png">')
from2 = connection.quote('[img]/images/emoticons/happy.png[/img]')
to = connection.quote(':)')
connection.execute(%Q{
update your_table
set your_column = replace(replace(your_column, #{from1}, #{to}), #{from2}, #{to}))
})