This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
Split string
|
Split string ( stringToSplit ; separator {; options} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
stringToSplit | Text |
![]() |
String value | |||||
separator | Text |
![]() |
String at which stringToSplit splits. If empty string (""), each character of stringToSplit is a substring | |||||
options | Longint |
![]() |
Option(s) regarding empty strings and spaces | |||||
Function result | Collection |
![]() |
Collection of substrings | |||||
The Split string command returns a collection of strings, created by splitting stringToSplit into substrings at the boundaries specified by the separator parameter. The substrings in the returned collection do not include separator itself.
If no separator is found in stringToSplit, Split string returns a collection containing a single element, stringToSplit. If you passed an empty string in separator, Split string returns a collection of each character of stringToSplit.
In the options parameter, you can pass one or a combination of the following constants from the Strings theme:
Constant | Type | Value | Comment |
sk ignore empty strings | Longint | 1 | Remove empty strings from the resulting collection (they are ignored) |
sk trim spaces | Longint | 2 | Trim space characters at the beginning and end of substrings |
C_TEXT($vt)
C_COLLECTION($col)
$col:=New collection
$vt:="John;Doe;120 jefferson st.;Riverside;; NJ; 08075"
$col:=Split string($vt;";") //["John","Doe","120 jefferson st.","Riverside",""," NJ"," 08075"]
$col:=Split string($vt;";";sk ignore empty strings) //["John","Doe","120 jefferson st.","Riverside"," NJ"," 08075"]
$col:=Split string($vt;";";sk ignore empty strings+sk trim spaces) //["John","Doe","120 jefferson st.","Riverside","NJ","08075"]
The separator parameter can be a multiple-character string:
C_TEXT($vt)
C_COLLECTION($col)
$vt:="Name<tab>Smith<tab>age<tab>40"
$col:=Split string($vt;"<tab>")
//$col=["Name","Smith","age","40"]
Product: 4D
Theme: String
Number:
1554
Created: 4D v16 R6
4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)