Split string with zsh as in Python

The solution is to use the @ modifier, as indicated in the zsh docs:

string="1::3"
a=("${(@s/:/)string}") # @ modifier

By the way, if one has the choice of the delimiter, it’s much easier and less error prone to use a newline as a delimiter. The right way to split the lines with zsh is then:

a=("${(f)string}")

I don’t know whether or not the quotes are necessary here as well…

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)