HTML-tags opschonen in alle posts na migratie?

Here’s code that does something similar:

posts=Post.where("raw like '%Sent from%using Tapatalk'")

posts.each do |post|
   post.raw.gsub!(/^Sent from my.+?using Tapatalk$/,"")
   post.save
   post.rebake!
end

I don’t think that you need to do something “smart” for images or URLs unless they are somehow broken.

You want something like

   post.raw.gsub!(/\/?\[p\]/ig,"\n")

to replace [p] and [/p] with a newline (an extra newline won’t hurt, but you can remove the \n if you don’t think you need a newline), but I haven’t tested, so this is probably wrong. You can test in something like https://rubular.com/.