H
Helmut Jarausch
Hi,
I'm looking for an elegant solution to the following (quite common)
problem:
Given a string of substrings separated by white space,
split this into tuple/list of elements.
The problem are quoted substrings like
abc "xy z" "1 2 3" "a \" x"
should be split into ('abc','xy z','1 2 3','a " x')
For that, one probably has to protect white space between
quotes, then split by white space and finally converted the
'protected white space' to normal white space again.
Is there an elegant solution - perhaps without using a lexer
and something else. With regular expressions alone it seems
clumsy.
Many thanks for a hint,
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
I'm looking for an elegant solution to the following (quite common)
problem:
Given a string of substrings separated by white space,
split this into tuple/list of elements.
The problem are quoted substrings like
abc "xy z" "1 2 3" "a \" x"
should be split into ('abc','xy z','1 2 3','a " x')
For that, one probably has to protect white space between
quotes, then split by white space and finally converted the
'protected white space' to normal white space again.
Is there an elegant solution - perhaps without using a lexer
and something else. With regular expressions alone it seems
clumsy.
Many thanks for a hint,
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany