# 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:** Product Support\
**Created:** [27. Oktober 2017 um 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:** 16

<div class="post-metadata">

**Author:** ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)\
**Post date:** [27. Oktober 2017 um 17:53 UTC](https://meta.discourse.org/t/how-to-replace-a-string-character-in-topic-title/72922/16 "2017-10-27T17:53:49Z")

</div>

thanks @pfaffman , @zogstrip

it has been solved as suggested, and I only needed to put space in the find code:

```plaintext
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)._
