4D v19

Split string

Home

 
4D v19
Split string

Split string 


 

Split string ( stringToSplit ; separator {; options} ) -> Function result 
Parameter Type   Description
stringToSplit  Text in String value
separator  Text in String at which stringToSplit splits. If empty string (""), each character of stringToSplit is a substring
options  Longint in Option(s) regarding empty strings and spaces
Function result  Collection in 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 case insensitive Longint 2

Strings are compared according to the current data language with no consideration of capitalization differences. Note that diacritical marks are taken into consideration. For example, "A" is considered the same as "a", however "a" is not considered the same as "à" . 

 

Can be combined with: 

  • sk char codes
  • sk diacritic insensitive
  • sk kana insensitive
  • sk strict
  • sk whole word (Position command only)
sk char codes Longint 1

Strings are compared according to character codes. Current data language settings are not taken into account during the comparison. 

 

Can be combined with: sk case insensitive 

Only for "a-z" or "A-Z" ranges. (e.g., Alpha = alpha, but Alpha # âlphà)

sk diacritic insensitive Longint 4

Strings are compared according to the current data language, however the diacritical mark (e.g., accent or symbol) of letters is ignored. For example, "a" is considered the same as "à". 

 

Can be combined with:

  • sk case insensitive
  • sk kana insensitive
  • sk strict
  • sk width insensitive
  • sk whole word (Position command only)
sk ignore empty strings Longint 1 Remove empty strings from the resulting collection (they are ignored)
sk kana insensitive Longint 8

For Japanese language. Strings are compared according to the meaning (not the writing style) in the current data language. For example, "あ" is considered the same as "ア". 

When this option is set, sk width insensitive is implicit (considered set), however, the opposite is not true.

 

Can be combined with:

  • sk case insensitive
  • sk diacritic insensitive
  • sk strict
  • sk width insensitive
sk strict Longint 0

Strings are compared for exact matches according to the current data language. In most cases, capitalization and diacritical marks of letters are taken into account during the comparison. 

 

Can be combined with:

  • sk case insensitive
  • sk diacritic insensitive
  • sk kana insensitive
  • sk width insensitive
sk trim spaces Longint 2 Trim space characters at the beginning and end of substrings
sk whole word Longint 32

Strings are compared according to the current data language. Only strings that are complete words are considered. Matching strings within other strings are not considered. For example, "where" is not considered when found within "somewhere".

 

Can be combined with: 

  • sk case insensitive (Position command only)
  • sk diacritic insensitive (Position command only)
sk width insensitive Longint 16

For Japanese language. Strings are compared by character width according to the current data language. For example, "ア" is considered the same as "ア". 

 

Can be combined with:

  • sk case insensitive
  • sk diacritic insensitive
  • sk kana insensitive
  • sk strict

 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"]



See also 

collection.join( )
TEXT TO ARRAY

 
PROPERTIES 

Product: 4D
Theme: String
Number: 1554

This command can be run in preemptive processes

 
HISTORY 

Created: 4D v16 R6

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)