I would like to split a string using shlex
(because I have to preserve text in quotes), but I do not want it to split over dots.
My code is the following:
import shlex
my_splitter = shlex.shlex('''foo, bar, "one, two", three four, 2.15''', posix=True)
my_splitter.whitespace += ','
my_splitter.whitespace_split = True
print(list(my_splitter))
output
['foo', 'bar', 'one, two', 'three', 'four', '2', '.', '15']
I do not want it to split '2.15'
into '2','.','15'