I have a function which accepts a string parameter such as: “var1=val1 var2=val2 var3=’a list of vals'”;
I need to parse this string and pick out the var/val combination’s. That is easy enough until introducing something like var3=’a list of vals’. Obviously I can’t explode the string into an array using a white space delimiter which has me kind of stuck. I want to create an array from this string with the var/val pairs properly assigned, how can I do this in a case where I have something like var3?
if the format of the string is set in stone, you could do something like:
EDIT:
More robust function that handles escaped chars in the quoted values: