How to parse data with fixed length but no separators


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,

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

will do it.


Excellent. This works perfectly for me.


(system) #4

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