# How to trim zero or more leading and trailing spaces from key-value pairs?

**URL:** https://discuss.elastic.co/t/how-to-trim-zero-or-more-leading-and-trailing-spaces-from-key-value-pairs/117933
**Category:** Logstash
**Created:** [February 1, 2018, 5:37am UTC](https://discuss.elastic.co/t/how-to-trim-zero-or-more-leading-and-trailing-spaces-from-key-value-pairs/117933 "2018-02-01T05:37:43Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![jainbhavya53](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@jainbhavya53](https://discuss.elastic.co/u/jainbhavya53)
#### Post date: [February 1, 2018, 6:46am UTC](https://discuss.elastic.co/t/how-to-trim-zero-or-more-leading-and-trailing-spaces-from-key-value-pairs/117933/7 "2018-02-01T06:46:19Z")

</div>

@Christian_Dahlqvist the `gsub` `regex` is not removing spaces around `=`.

![shot](https://us1.discourse-cdn.com/elastic/original/3X/2/2/22562abb08902c929da26f653f34439639b3add5.png)

---

_[View the full topic](https://discuss.elastic.co/t/how-to-trim-zero-or-more-leading-and-trailing-spaces-from-key-value-pairs/117933)._
