Fn::Split splits a string into a list of values based on a specified delimiter.
Declaration
-
JSON
{ "Fn::Split": [ "delimiter", "original_string" ] } -
YAML
-
Syntax for the full function name:
Fn::Split: - delimiter - original_string -
Syntax for the short form:
!Split [delimiter, original_string]
-
Parameters
-
delimiter: the delimiter, such as a comma (,), a semicolon (;), a line feed (\n), or an indent (\t). -
original_string: the string to split.
Return value
A list of the split string values.
Examples
-
The following example splits a string into an array of values:
!Split - ; - foo; bar; achoo{ "Fn::Split": [ ";", "foo; bar; achoo" ] }This example returns
["foo","bar","achoo"]. -
The following example splits the value of InstanceIds:
Parameters: InstanceIds: Type: String Default: instane1_id,instance2_id,instance2_id Resources: a: Type: ALIYUN::SLB::BackendServerAttachment Properties: BackendServerList: !Split - ',' - !Ref InstanceIds{ "Parameters": { "InstanceIds": { "Type": "String", "Default": "instane1_id,instance2_id,instance2_id" } }, "Resources": { "a": { "Type": "ALIYUN::SLB::BackendServerAttachment", "Properties": { "BackendServerList": { "Fn::Split": [ ",", {"Ref": "InstanceIds"} ] } } } } }