Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter EightData Functions (continued)

ExplodeString Function

Overview

The ExplodeString function separates string components into an array of strings based on a delimiter string.

Syntax/Parameters

Syntax

string[] = ExplodeString ( string data, [string delimiter], [int limit] );

Parameters

data

A string containing data to explode.

delimiter

An optional string that defines the delimiter that will be used to separate the string. The delimiter segments are not placed in the resulting array except for the last item in certain circumstances. If the delimiter is omitted or an empty string is provided, the data string is treated as lines of text separated by “\r” or “\r\n”.

limit

An optional int specifying a limit to the number of items to explode. If omitted, all segments between matching delimiters are placed in the array. If a positive number is used, the array will be filled with a maximum of that number of items plus a last item containing remaining unprocessed data, if any. If a negative number is provided, the array will be filled with a maximum of that number of items and any remaining data will be discarded. The value cannot be 0 and a delimiter must be provided to use this parameter.

Return Value

Returns a string array containing each string segment and potentially a last entry with any remaining unprocessed data.

Remarks

The ExplodeString function is an extremely powerful string processing tool. It can be used to read in and index a file by lines. Scripts can also explode sections of a string to the limit parameter and then process the remaining data from the last item at the limit position. However, for reading certain uncontrolled data types such as when parsing CSV data, this function is not sophisticated. For example, the CSV functions will take into account escape quotes while this function will treat all quotes in the same manner.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic