I have a string that i must parse, setting a classes vars correctly from it. The string is badly structured but i can not change it. I have tried parsing it but dont have a good way to do it without issue. The string itself is a set of attributes and params that are used to trigger a exe from cmd line.
I have laid it out in a way to make easier to read but know that is it 1 continuous string.
Here are the rules as to how to read this line. For every 'non -dll' command you can expect a single key and value pair. for the dlls lines you can have a single or multiple key-value pairs after the initial dll=,' ie the 'dll' element contains 0 or more keyValue or stand alone value split by spaces. eg dll=oneMoreDll, andItsParam=value anotherParam=value lastParam=value value
Input string
time=value1 size=value2 dll=aDllName dll=anotherDllName, someParam=ParamValue dll=yetAnotherDll, someOhterParam=anotherParamValue aStandAloneValue dll=oneMoreDll, andItsParam=value anotherParam=value lastParam=value
I want to be able to parse this string into the following format, i was thinking each line in a string array.
I have tried splitting by spaces and then 'dll' but my regex aint up to scratch or its impossible (im sure its not). Help!
Desired output elements, to be stored in a String array
time=value1
size=value2
dll=aDllName
dll=anotherDllName, someParam=ParamValue
dll=yetAnotherDll, someOhterParam=anotherParamValue aStandAloneValue
dll=oneMoreDll, andItsParam=value anotherParam=value lastParam=value