<p><code>customAsciiCharMappings</code> won't help you here.</p>

<p>There is the "Find and Replace" tool available to admins (Settings->Tools) in the Control Panel, but its' a one-off thing and searches/replaces against <em>all</em> textual field types (Plain Text, Rich Text, etc. both inside and outside of Matrix fields).</p>

<p>Honestly, probably just create a small Twig macro that wraps <code>|replace</code> and use that wherever you're outputting Rich Text fields on the site.</p>

CC BY-SA 3.0
2017-09-15T17:34:38.257Z
Awesome, thanks! I'm not sure the macro would be more convenient than manually wrapping them all in `|replace` but that looks like the best way.
jtenclay
CC BY-SA 3.0
2017-09-14T15:50:04.613Z
2017-09-14T15:50:04.613Z
Brad Bell
<p>I'm looking to dynamically replace the ℠ glyph with <code>&lt;sup&gt;SM&lt;/sup&gt;</code> in all rich text fields, since that glyph doesn't exist in the font we're using. I'd like to avoid having to call the <code>|replace</code> filter on every field in every template, and I can't seem to get the <code>customAsciiCharMappings</code> general config setting to work either (I'm not sure if I really understand what it does). Does Craft have something like a global replace function/filter?</p>

<redactor><richtext><replace>
Can I call a filter on all Rich Text fields?
# Can I call a filter on all Rich Text fields?

(Asked by: username_0 on 2017-09-14)

I'm looking to dynamically replace the ℠ glyph with `SM` in all rich text fields, since that glyph doesn't exist in the font we're using. I'd like to avoid having to call the `|replace` filter on every field in every template, and I can't seem to get the `customAsciiCharMappings` general config setting to work either (I'm not sure if I really understand what it does). Does Craft have something like a global replace function/filter?

**Tags:** redactor, richtext, replace

---

## 1 answers

### Answer by username_1 on 2017-09-14. Score: 1 | Accepted answer

`customAsciiCharMappings` won't help you here.

There is the "Find and Replace" tool available to admins (Settings->Tools) in the Control Panel, but its' a one-off thing and searches/replaces against *all* textual field types (Plain Text, Rich Text, etc. both inside and outside of Matrix fields).

Honestly, probably just create a small Twig macro that wraps `|replace` and use that wherever you're outputting Rich Text fields on the site.

> **Comments:**
> **username_0**: Awesome, thanks! I'm not sure the macro would be more convenient than manually wrapping them all in `|replace` but that looks like the best way.  

---

