Sometimes we want to not split by every space character, but we want to split only on those outside of brackets and quotes. This way we can have for example quoted string as single argument for command.
EDIT:
- Added hierarchical nesting of same kind of brackets.
- Bunching multiple separators as single separator, None as general whitespace separator
Test output:
----------------------------------------------------------------------------------------------------------------------------------
Hello, (Tony 'pyTony' Jarkko Veijalainen)
{'This 'is' quoted' Great to "split" this} split "Also Quoted part" [test test] end
Hello,
(Tony 'pyTony' Jarkko Veijalainen)
{'This 'is' quoted' Great to "split" this}
split
"Also Quoted part"
[test test]
end
---------------------------------------------------------------------------------------------------------------------------------
Hello, (Tony Jarkko Veijalainen) "This ("is") quoted" Great to "split" {this split} "Also Quoted part" [test test] end
Hello,
(Tony Jarkko Veijalainen)
"This ("is") quoted"
Great
to
"split"
{this split}
"Also Quoted part"
[test test]
end
------------------------------------------------------------------------------------------------------------------------------
Hello, (Tony Jarkko Veijalainen This ("is")' quoted Great, to split this split "Also Quoted part" [test split test] end
Did not find end of pair for '(': ')'
43:Hello, (Tony Jarkko Veijalainen This ("is")
------------------------------------------------------------------------------------------------------------------------
Hello, [Tony Jarkko Veijalainen) "This ("is") quoted" Great, to split this split "Also Quoted part" test split test end
Did not find end of pair for '[': ']'
8:Hello, [
----------------------------------------------------
[(An (even better)) [Lisp Interpreter [in Python]]]
[(An (even better)) [Lisp Interpreter [in Python]]]