# How to parse data with fixed length but no separators

**URL:** <https://discuss.elastic.co/t/how-to-parse-data-with-fixed-length-but-no-separators/131772>\
**Category:** Logstash\
**Created:** [May 14, 2018, 3:17pm UTC](https://discuss.elastic.co/t/how-to-parse-data-with-fixed-length-but-no-separators/131772 "2018-05-14T15:17:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjwang](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tjwang](https://discuss.elastic.co/u/tjwang)\
**Post date:** [May 14, 2018, 3:17pm UTC](https://discuss.elastic.co/t/how-to-parse-data-with-fixed-length-but-no-separators/131772/1 "2018-05-14T15:17:59Z")

</div>

My data is a big plain text file with multiple sections with definite lengths but no separators like below

"aabb111222Test ABC20080502  
ccdd333444Test EFG20080503  
......"

The first section has length 4, such as "aabb" or "ccdd";  
The second section has length 6, such as "111222" or "333444";  
The third section has length 8, such as "Test ABC" or "Test EFG";  
The forth section has length 8 as a date, such as "20080502" or "20080503";  
and so on...

What filters or patterns can be used to parse the data like this?

Many thanks,

---

<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:** [May 14, 2018, 4:26pm UTC](https://discuss.elastic.co/t/how-to-parse-data-with-fixed-length-but-no-separators/131772/2 "2018-05-14T16:26:24Z")

</div>

> [@tjwang](#):
>
> ccdd333444Test EFG20080503

```
grok { match => ["message", "^(?<f1>.{4})(?<f2>.{6})(?<f3>.{8})(?<f4>.{8})"] }

```

will do it.

---

<div class="post-metadata">

**Author:** ![tjwang](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tjwang](https://discuss.elastic.co/u/tjwang)\
**Post date:** [May 14, 2018, 5:08pm UTC](https://discuss.elastic.co/t/how-to-parse-data-with-fixed-length-but-no-separators/131772/3 "2018-05-14T17:08:08Z")

</div>

Excellent. This works perfectly for me.

Thanks,

---

<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:** [June 11, 2018, 5:08pm UTC](https://discuss.elastic.co/t/how-to-parse-data-with-fixed-length-but-no-separators/131772/4 "2018-06-11T17:08:15Z")

</div>

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