Hello I have a programming question.. looking to do this in an elegant way using reg-ex if possible...
Here is the scenario.. I have lines of data I need to process - which ultimately I want to use the 'split' cmd on (space delimited). However, some fields have spaces in the field - these fields will be encapsulated with double quotes. Any field may be a " ... " field - and the number of fields on a line can be variable.
I know how to do this if there is only one " " field on the line... when there is 1 or more of those fields allowed, that's where I get stuck.
2 Example data lines:
AA_1 "field with spaces" BB_3 CC_5 AB_2 DD_4 "this has spaces" ZZ_3 "more spaces here" CC_1
I'd like to transform the lines above to: AA_1 field##with##spaces BB_3 CC_5 AB_2 DD_4 this##has##spaces ZZ_3 more##spaces##here CC_1
So, I just want to replace any / all " .." encapsulated field(s) with the field - each space replaced by ##, and remove the leading and trailing double quotes.
Once I have this, I can easily do a 'split' on the lines - w/ space as the delimiter. And once I have the entries in the array, I'll simply translate the ## back to a space character ( I know there cannot be ## in any incoming field in the string).