가장 빠른 방법은 수 있도록하는 것입니다 데이터베이스는 모든 작업을 수행합니다
소스 또는 대상 문자열은 따옴표 (포함
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하지 않은 경우 손으로 it 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}))
})