# Adding characters to a field

**URL:** https://discuss.elastic.co/t/adding-characters-to-a-field/215513
**Category:** Logstash
**Created:** [January 17, 2020, 8:05pm UTC](https://discuss.elastic.co/t/adding-characters-to-a-field/215513 "2020-01-17T20:05:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![megajune](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/megajune/32/47012_2.png) [@megajune](https://discuss.elastic.co/u/megajune)
#### Post date: [January 17, 2020, 8:05pm UTC](https://discuss.elastic.co/t/adding-characters-to-a-field/215513/1 "2020-01-17T20:05:33Z")

</div>

I have this value in a field:

881908396bfd

I want to format it like this:

88:19:08:39:6b:fd

What's the "best" way to do that?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [January 17, 2020, 10:52pm UTC](https://discuss.elastic.co/t/adding-characters-to-a-field/215513/2 "2020-01-17T22:52:52Z")

</div>

```
if [someFieldName] =~ /^[0-9a-z]{12}$/ {
    mutate { gsub => ["someFieldName", "^([0-9a-z][0-9a-z])([0-9a-z][0-9a-z])([0-9a-z][0-9a-z])([0-9a-z][0-9a-z])([0-9a-z][0-9a-z])([0-9a-z][0-9a-z])", "\1:\2:\3:\4:\5:\6" ] }
}
```

---

<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: [February 14, 2020, 10:52pm UTC](https://discuss.elastic.co/t/adding-characters-to-a-field/215513/3 "2020-02-14T22:52:55Z")

</div>

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