Consider this:
command1 -keep -path { {path1} } { {./input.doc} }
I wanted to parse the above line and collect the information into a map where value would be contents of -path option and key would be everything else. The format of the string would be fixed that after -path there would be two opening and two closes brackets. In this case,
key would be:
command1 -keep { {./input.doc} }
Value would be:
path1
I was doing it using brute force method as like:
Get the position of -path.
Get the position of second closing bracket.
Little more processing and create two substring of -path and remaining else with above two positions.
This seems little rusty to me. Can we discuss other methods to extract this information?
Aucun commentaire:
Enregistrer un commentaire