I'm looking for an existing swift2 function to split string input on whitespace while at the same time preserving whitespace within quoted strings.
I have read stack overflow question 25678373. My question does not appear to be a duplicate.
I searched for similar functionality in cocoapods. I did not find it.
If this shlex.split function does not exist in swift2, what is an effective alternate way to accomplish something similar? What is an alternate way to split a string while preserving whitespace within internal quoted strings?
Here's an example of what I mean in python:
$ python
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> input=""" alpha 2 'chicken with teeth' 4 'cat with wings' 6 turkey"""
>>> results = shlex.split(input)
>>> type(results)
<type 'list'>
>>> results[0]
'alpha'
>>> results[2]
'chicken with teeth'
>>> for term in results:
... print(term)
...
alpha
2
chicken with teeth
4
cat with wings
6
turkey
>>>