# How to use replace to replace two words in a paragraphe

**URL:** https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134
**Category:** support
**Created:** [October 30, 2020, 5:43pm UTC](https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134 "2020-10-30T17:43:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Argus\_Panoptes](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/argus_panoptes/32/12640_2.png) [@Argus\_Panoptes](https://discourse.gohugo.io/u/Argus_Panoptes)
#### Post date: [October 30, 2020, 5:43pm UTC](https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134/1 "2020-10-30T17:43:21Z")

</div>

i want to replace two words using replace but i’m unable to do that

{{ replace “Batman and Robin” “Robin” “Catwoman” }} or {{ replace “hyde and jekyll” “jekyll” “Hugo” }}

i have tried `or` but it didn’t work

---

<div class="post-metadata">

### Author: ![Hrishikesh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hrishikesh/32/19176_2.png) [@Hrishikesh](https://discourse.gohugo.io/u/Hrishikesh)
#### Post date: [October 30, 2020, 6:44pm UTC](https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134/2 "2020-10-30T18:44:47Z")

</div>

You can use Regex. `{{ replaceRE "(Batman)|(Robin)" ... }}`. Is that what you’re looking for?

---

<div class="post-metadata">

### Author: ![Argus\_Panoptes](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/argus_panoptes/32/12640_2.png) [@Argus\_Panoptes](https://discourse.gohugo.io/u/Argus_Panoptes)
#### Post date: [October 30, 2020, 8:22pm UTC](https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134/3 "2020-10-30T20:22:58Z")

</div>

thanks for your reply, but i want to replace both robin and jekyll in the same line

---

<div class="post-metadata">

### Author: ![Hrishikesh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hrishikesh/32/19176_2.png) [@Hrishikesh](https://discourse.gohugo.io/u/Hrishikesh)
#### Post date: [October 30, 2020, 8:35pm UTC](https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134/4 "2020-10-30T20:35:40Z")

</div>

Oh so, do you mean you want to replace the following strings:

`Batman and Robin`, `Robin`, `Catwoman` or `hyde and jekyll`, `jekyll`, `Hugo`?

It can work something like:

`{{ replaceRE "(Batman and Robin)|(Robin)|(Catwoman)|{hyde and jekyll)|(jekyll)|(Hugo)" ... }}`

Sadly, I’m having trouble understanding how exactly you want the text to be grouped. But, I can explain my code in my previous answer so you can just modify and use it:

`(...)` anything between those brackets would be marked as an entire group. So, if you want to find the entire phrase `foo plus bar`, you can use it like `(foo plus bar)`.

`|` is the `or` separator. It will stand for anything before or after that. For example, if you want to search for `foo` or `bar`, you can use it like `foo|bar`.

Does that help?

---

<div class="post-metadata">

### Author: ![Argus\_Panoptes](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/argus_panoptes/32/12640_2.png) [@Argus\_Panoptes](https://discourse.gohugo.io/u/Argus_Panoptes)
#### Post date: [October 30, 2020, 8:51pm UTC](https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134/5 "2020-10-30T20:51:38Z")

</div>

this one is working perfectly \>\>\> {{ (replace $name “teaching-and-academics” “academics” ) }}

now i also want to replace ( “photography-and-video” “photography”) that are in the same line

i’ve tried that but it didn’t work 😔

` {{ (replace $name ("teaching-and-academics" "academics") | ("photography-and-video" "photography") |}}`

---

<div class="post-metadata">

### Author: ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)
#### Post date: [October 31, 2020, 2:53am UTC](https://discourse.gohugo.io/t/how-to-use-replace-to-replace-two-words-in-a-paragraphe/29134/6 "2020-10-31T02:53:14Z")

</div>

Try nesting two `replace` calls. The inner call becomes the input to the outer call.

```auto
{{ replace (replace $name "teaching-and-academics" "academics") "photography-and-video" "photography" }}

```
