split将字符串拆分成数组

split将字符串拆分成数组

ZKEASOFT August 28, 2018


split

split使用参数作为分隔符将输入字符串分成数组。 split通常用于将逗号分隔的项从字符串转换为数组。

输入

{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}

{% for member in beatles %}
  {{ member }}
{% endfor %}

输出

John
Paul
George
Ringo

微信公众号