# Replace tab character with rake task?

**URL:** https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484
**Category:** Support
**Created:** [February 25, 2018, 6:55pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484 "2018-02-25T18:55:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [February 25, 2018, 6:55pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/1 "2018-02-25T18:55:04Z")

</div>

I’ve got a bunch of posts with lines that start with a tab character (`&#9;`), and they look like this:

```
The first line of a paragraph 

```

is shown as preformatted text.

`rake posts:remap["&#9;","\ "]` is not finding anything to remap. Is there a way to replace the tab character?

---

<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: [February 25, 2018, 9:37pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/2 "2018-02-25T21:37:01Z")

</div>

Try

```
rake posts:remap["\t","\ "]

```

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [February 25, 2018, 9:46pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/3 "2018-02-25T21:46:57Z")

</div>

Are you sure, Jay?

`Are you sure you want to replace all string occurrences of 't' with ' '? (Y/n)`

I migh end up wi h a lo of missing ee h! 😬

---

<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: [February 25, 2018, 9:57pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/4 "2018-02-25T21:57:12Z")

</div>

No. I’m not sure. But if that’s the message you got, you might try

```
rake posts:remap["\\t","\ "]

```

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [February 25, 2018, 9:59pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/5 "2018-02-25T21:59:08Z")

</div>

I get an identical confirmation message as with a single backslash.

---

<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: [February 25, 2018, 10:02pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/6 "2018-02-25T22:02:37Z")

</div>

Hmm. Maybe

```
rake posts:remap['\t',"\ "]

```

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [February 25, 2018, 10:04pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/7 "2018-02-25T22:04:24Z")

</div>

Still the same message…

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [February 25, 2018, 10:10pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/8 "2018-02-25T22:10:15Z")

</div>

Perhaps the task needs to be told explicitly to use regex with a type argument?

> <https://github.com/discourse/discourse/blob/main/lib/tasks/posts.rake#L154-L155>

Edit:

```
rake posts:remap["\t","\ ",regex]
Are you sure you want to replace all regex occurrences of 't' with ' '? (Y/n)

```

But, I am still not sure if this would remove all **t** characters.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 13, 2020, 8:51pm UTC](https://meta.discourse.org/t/replace-tab-character-with-rake-task/81484/9 "2020-06-13T20:51:02Z")

</div>


