<p>In Twig, you never want to use delimiters inside other delimiters (e.g. <code>{{ ... {{ ... }} }}</code>).</p>

<p>Here's how you would format it instead:</p>

<pre><code>&lt;h3&gt;{{ wordBoldTitle | replace('#', '&lt;strong class="font-weight-extra-bold"&gt;' ~ entry.title ~ '&lt;/strong&gt;') | raw }}&lt;/h3&gt;
</code></pre>

<p>What we're doing here is using Twig <a href="https://twig.symfony.com/doc/3.x/templates.html#other-operators" rel="nofollow noreferrer">concatenation</a> (via the <code>~</code> operator) to combine our first string (<code>&lt;strong class="font-weight-extra-bold"&gt;</code>), whatever string <code>entry.title</code> results in, and then our second string (<code>&lt;/strong&gt;</code>).</p>

<p>Alternatively we can use <a href="https://twig.symfony.com/doc/3.x/templates.html#string-interpolation" rel="nofollow noreferrer">string interpolation</a> to achieve this; however string interpolation requires double-quotes, so to do this we'll need to escape the double quotes already in our string:</p>

<pre><code>&lt;h3&gt;{{ wordBoldTitle | replace("#", "&lt;strong class=\"font-weight-extra-bold\"&gt;${entry.title}&lt;/strong&gt;") | raw }}&lt;/h3&gt;
</code></pre>

<hr>

<p>I also changed your replace filter from using a hash (e.g. <code>{'#':'xxx'}</code> to the simpler (at least in this case) comma-separated parameters. The hash works well if you need to replace multiple items, but the comma-separated parameters looks cleaner in my opinion when you only need to replace one item. You can find more about the replace filter formatting <a href="https://docs.craftcms.com/v3/dev/filters.html#replace" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2019-11-20T16:12:40.173Z
Works like a charm. Thank you
Jason
CC BY-SA 4.0
2019-11-20T14:55:23.990Z
2019-11-20T14:55:23.990Z
Jalen Davenport
<p>Good morning and thank you in advance. How can I replace '#' with the entry.title. I have tried everything and I keep getting hash errors. Current code is this:</p>

<pre><code>&lt;h3&gt;{{ wordBoldTitle|replace({'#':'&lt;strong class="font-weight-extra-bold"&gt;{{entry.title}}&lt;/strong&gt;'} )|raw }}&lt;/h3&gt;
</code></pre>

<p>Trying to concatenate the  with the entry.title. </p>

<craft3><entries><replace>
Replace # with entry.title
# Replace # with entry.title

(Asked by: username_0 on 2019-11-20)

Good morning and thank you in advance. How can I replace '#' with the entry.title. I have tried everything and I keep getting hash errors. Current code is this:
{{ wordBoldTitle|replace({'#':'{{entry.title}}'} )|raw }}

Trying to concatenate the  with the entry.title.

**Tags:** craft3, entries, replace


---

## 1 answers

### Answer by username_1 on 2019-11-20. Score: 2 | Accepted answer

In Twig, you never want to use delimiters inside other delimiters (e.g. {{ ... {{ ... }} }}).
Here's how you would format it instead:
{{ wordBoldTitle | replace('#', '' ~ entry.title ~ '') | raw }}

What we're doing here is using Twig concatenation (via the ~ operator) to combine our first string (), whatever string entry.title results in, and then our second string ().
Alternatively we can use string interpolation to achieve this; however string interpolation requires double-quotes, so to do this we'll need to escape the double quotes already in our string:
{{ wordBoldTitle | replace("#", "${entry.title}") | raw }}


I also changed your replace filter from using a hash (e.g. {'#':'xxx'} to the simpler (at least in this case) comma-separated parameters. The hash works well if you need to replace multiple items, but the comma-separated parameters looks cleaner in my opinion when you only need to replace one item. You can find more about the replace filter formatting here.

> **Comments:**
> **username_0**: Works like a charm. Thank you  

---

