# How to replace a string/character in topic title?

**URL:** https://meta.discourse.org/t/how-to-replace-a-string-character-in-topic-title/72922
**Category:** Support
**Created:** [10월 27, 2017, 10:44오전 UTC](https://meta.discourse.org/t/how-to-replace-a-string-character-in-topic-title/72922 "2017-10-27T10:44:12Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [10월 27, 2017, 4:29오후 UTC](https://meta.discourse.org/t/how-to-replace-a-string-character-in-topic-title/72922/11 "2017-10-27T16:29:59Z")

</div>

Here’s my try. It’s not tested, so please backup first!

I don’t know how this interacts with “encoded”. Perhaps that means that dashes are encoded as something other than a `-`. If that’s the case, you’ll need to modify things accordingly.

```ruby
Topic.where("title LIKE '%-%'").find_each do |topic|
  topic.title.gsub!(/-/," ")
  topic.fancy_title.gsub!(/-/," ")
  topic.slug.gsub!(/-/," ")
  puts topic.title
  begin
    topic.save!
  rescue
    puts "oops, something broke."
  end
end

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-replace-a-string-character-in-topic-title/72922)._
