I've written a parse to split a record into multiple column.
Below is my input file on which some record has 4 different values , some has only 3 and some has 5
:25:A1BC 0055555 USD |
:25:X1Y2 USD |
:25:HK13 49000000 USD NY |
And to achieve this i have written this into parse= (:25:)(\w+)(\s)(\d+)(\s)([A-Z]*[0-9]*)(\s)*([A-Z]*[0-9]*)
But this parse result is getting correct for 1st record line. but Null is coming for 2nd record line and 3rd is again right.
:25: | A1BC | 0055555 | USD | |
:25: | HK13 | 49000000 | USD | NY |
This is required output
:25: | A1BC | 0055555 | USD | |
:25: | X1Y2 | USD | ||
:25: | HK13 | 49000000 | USD | NY |
Can someone tell me what's going wrong here? Is the logic in parse wrong?
Solved! Go to Solution.
I think something like:
(:25:)(\w+)\s*(\d+)?\s([A-Z]*[0-9]*)\s*([A-Z]*[0-9]*)?
What I have done is marked a few blocks as optional (with a trailing ?) and made the spaces 0 or more.
Seems like it works with your example.
@AnandKumar1
In oder to make it work, we need more data to test it I think 😁