fixedlength icon indicating copy to clipboard operation
fixedlength copied to clipboard

Parsing String with variable element

Open jaysara opened this issue 1 year ago • 2 comments

I have a variable segments structure like,

A001{field1-2character}{field2-12characters}{field3-21characters}C001{field4-1character}{field5-10characters}{field6-13characters}D001{field7-12character}{field8-2characters}{field9-21characters}

another string can be

A001{field1-2character}{field2-12characters}{field3-21characters}B001{field11-5characters}{field12-8characters}{field13-3characters}D001{field7-12character}{field8-2characters}{field9-21characters}E001{field20-5characters}{field21-12characters}{field22-2characters}

As mentioned we have segments like A001, B001 , C001, D001, etc.. All segments have fixed format fields. However some segments may or may not be present in a given string. The parser needs to figure out whether a segment is there or not and execure parser logic specific to the segment.

Can this library help ?

jaysara avatar May 16 '24 01:05 jaysara

Okay, we could make it if we extend FixedLine with regexp or/and predicate functionality and you could pass your conditions there. Will it work for you?

g0ddest avatar May 16 '24 12:05 g0ddest

@jaysara , check out the PR :)

g0ddest avatar May 18 '24 12:05 g0ddest

I've merged predicate solution, try it :)

g0ddest avatar Aug 20 '24 14:08 g0ddest