# replaceRE error with escaped square bracket

**URL:** <https://discourse.gohugo.io/t/replacere-error-with-escaped-square-bracket/29860>\
**Category:** support\
**Created:** [December 7, 2020, 8:32am UTC](https://discourse.gohugo.io/t/replacere-error-with-escaped-square-bracket/29860 "2020-12-07T08:32:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hlegendre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hlegendre/32/12421_2.png) [@hlegendre](https://discourse.gohugo.io/u/hlegendre)\
**Post date:** [December 7, 2020, 8:32am UTC](https://discourse.gohugo.io/t/replacere-error-with-escaped-square-bracket/29860/1 "2020-12-07T08:32:18Z")

</div>

Hi !

I am trying to clean-up the [^1] footnotes syntax in a json layout to build a search index (as in [A simple javascript based full text search function](https://discourse.gohugo.io/t/a-simple-javascript-based-full-text-search-function/29119)).

When using ` | replaceRE "\[\^([^\]])+\]" " "`, I get an invalid syntax whereas I think it should not (this is proper RE as checked on [https://regex101.com](https://regex101.com) and in the Golang flavor.

Does anyone has a clue on how to make it work please ?

Best regards,

Hugues

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [December 7, 2020, 8:37am UTC](https://discourse.gohugo.io/t/replacere-error-with-escaped-square-bracket/29860/2 "2020-12-07T08:37:48Z")

</div>

> [@hlegendre](#):
>
> `replaceRE "\[\^([^\]])+\]" " "`

Try wrapping the regex in [backticks](https://www.computerhope.com/jargon/b/backquot.htm) instead of quotes i.e. `

---

<div class="post-metadata">

**Author:** ![hlegendre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hlegendre/32/12421_2.png) [@hlegendre](https://discourse.gohugo.io/u/hlegendre)\
**Post date:** [December 7, 2020, 10:02am UTC](https://discourse.gohugo.io/t/replacere-error-with-escaped-square-bracket/29860/3 "2020-12-07T10:02:00Z")

</div>

awesome ! thanks !

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [December 7, 2020, 1:15pm UTC](https://discourse.gohugo.io/t/replacere-error-with-escaped-square-bracket/29860/4 "2020-12-07T13:15:22Z")

</div>

Or backslash the quotes inside. But backticks work much better.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [December 9, 2020, 1:15pm UTC](https://discourse.gohugo.io/t/replacere-error-with-escaped-square-bracket/29860/5 "2020-12-09T13:15:25Z")

</div>

Closed on December 9, 2020, 1:15pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
