# Canvas replace function

**URL:** <https://discuss.elastic.co/t/canvas-replace-function/169019>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [February 19, 2019, 12:19pm UTC](https://discuss.elastic.co/t/canvas-replace-function/169019 "2019-02-19T12:19:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rozling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rozling/32/16401_2.png) [@rozling](https://discuss.elastic.co/u/rozling)\
**Post date:** [February 19, 2019, 12:19pm UTC](https://discuss.elastic.co/t/canvas-replace-function/169019/1 "2019-02-19T12:19:35Z")

</div>

I'm working with Canvas a lot at the moment so please excuse all the questions...

Can anyone give usage examples of the [replace](https://www.elastic.co/guide/en/kibana/current/canvas-common-functions.html#_replace) function?

I would expect something like this to work:

```
| mapColumn service fn={replace "-","_"}

```

which results in: `Unable to parse expression: Expected "|" or end of input but "=" found.`

or:

```
| mapColumn service.replace("-","_")

```

but this results in the error `Unable to parse expression: Expected "|" or end of input but "(" found.`

Am I misunderstanding something fundamental about this function?

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [February 20, 2019, 9:04pm UTC](https://discuss.elastic.co/t/canvas-replace-function/169019/2 "2019-02-20T21:04:28Z")

</div>

Try this:

```auto
| mapColumn service fn={getCell service | replace "-" replacement="_"}

```

---

<div class="post-metadata">

**Author:** ![rozling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rozling/32/16401_2.png) [@rozling](https://discuss.elastic.co/u/rozling)\
**Post date:** [February 25, 2019, 12:10pm UTC](https://discuss.elastic.co/t/canvas-replace-function/169019/3 "2019-02-25T12:10:15Z")

</div>

Hi Lukas,

That worked - thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 25, 2019, 12:10pm UTC](https://discuss.elastic.co/t/canvas-replace-function/169019/4 "2019-03-25T12:10:16Z")

</div>

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