# How to use .conut to exclude a character from the .length count?

**URL:** https://discuss.elastic.co/t/how-to-use-conut-to-exclude-a-character-from-the-length-count/284938
**Category:** Logstash
**Created:** [September 22, 2021, 7:51pm UTC](https://discuss.elastic.co/t/how-to-use-conut-to-exclude-a-character-from-the-length-count/284938 "2021-09-22T19:51:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rauly\_Koto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rauly_koto/32/79589_2.png) [@Rauly\_Koto](https://discuss.elastic.co/u/Rauly_Koto)
#### Post date: [September 22, 2021, 7:51pm UTC](https://discuss.elastic.co/t/how-to-use-conut-to-exclude-a-character-from-the-length-count/284938/1 "2021-09-22T19:51:45Z")

</div>

Currently it does the account but does not delete the "/".

```auto
ruby {
    		code => '
        		event.set("execution_length_input", event.get("[execution][input]").to_s.length - 
                        ("[execution][input]").to_s.count("\") )
			'
		}

```

---

<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: [September 22, 2021, 8:21pm UTC](https://discuss.elastic.co/t/how-to-use-conut-to-exclude-a-character-from-the-length-count/284938/2 "2021-09-22T20:21:24Z")

</div>

You could try

```
        code => '
            e = event.get("[execution][input]")
            if e
                event.set("execution_length_input", e.to_s.delete("/").length)
            end
        '
```

---

<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: [October 20, 2021, 8:22pm UTC](https://discuss.elastic.co/t/how-to-use-conut-to-exclude-a-character-from-the-length-count/284938/3 "2021-10-20T20:22:06Z")

</div>

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