# Escaping a backslash in a regex

**URL:** <https://meta.discourse.org/t/escaping-a-backslash-in-a-regex/324641>\
**Category:** Support\
**Created:** [September 3, 2024, 11:21am UTC](https://meta.discourse.org/t/escaping-a-backslash-in-a-regex/324641 "2024-09-03T11:21:13Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [September 3, 2024, 11:21am UTC](https://meta.discourse.org/t/escaping-a-backslash-in-a-regex/324641/1 "2024-09-03T11:21:13Z")

</div>

I wanna replace string title from “T8/2024” to “T9/2024”

from topic [How to replace a string/character in topic title? - #11 by pfaffman](https://meta.discourse.org/t/how-to-replace-a-string-character-in-topic-title/72922/11)

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

```

**But i get error:**

```plaintext
SyntaxError: unexpected integer literal, expecting ')'
  topic.title.gsub!(/T8/2024/,"T9/2024")
                        ^~~~

```

If the word you want to replace has the character “/”, how should we handle it?

---

_[View the full topic](https://meta.discourse.org/t/escaping-a-backslash-in-a-regex/324641)._
