MicroStrategy ONE
Split
The Split
function searches a string, separates the contents into groups of characters based on a delimiter, and returns the string of characters requested. For example, you can search a string of characters that separates values with commas, and return the characters after the first comma. Searching the string "
red, yellow, green"
and selecting to return the second set of characters based on a comma as the delimiter returns "
yellow "
.
Syntax
Split<SeparatorRegex=False>(
String
,
Delimiter, Index
)
Where:
String
is a metric, fact, column, or string representing the text strings that are searched.-
Delimiter
is a metric, fact, column, or string that determines the characters used to separate each concatenated value. A common practice is to provide a constant text value for the delimiter. Typing "," uses a comma as the delimiter.You can also choose to use regular expressions to define the delimiter characters. For information on supporting regular expressions, see the
SeparatorRegex
parameter described below.If the delimiter character is not found in the string of characters, one of two resolutions can occur:
- If you define
Index
as 1, then the entire string of characters is returned. - If you define
Index
as any value other than 1, aNULL
value is returned.
- If you define
Index
is a metric, fact, column, or constant value that determines which group of characters are returned. A common practice is to provide a constant numerical value. For example, using a value of 1 returns the first group of characters before the first delimiter characters are found in the string.SeparatatorRegex
is a parameter that determines if a regular expression is used to provide the delimiter characters. The regular expressions supported by this function conform to the standards of the Intern a ion al Components for Unicode. For information about these regular expression standards and syntax, see http://userguide.icu-project.org/strings/regexp.
Example
-
Split<SeparatorRegex=True>("red yellow green", "\s", 2)
This returns the string of characters
"
yellow"
. By using the regular expression\s
, any white space character is considered a delimiter. This splits the string into the strings"
red"
,"
yellow"
, and"
green".
-
Split("red; yellow; green", ";" 1)
This returns the string of characters
"
red".
-
Split("red; yellow; green", ";" 3)
This returns the string of characters
"
green".
-
Split("red; yellow; green", ";" 4)
This returns a
NULL
value, since the string is only split into three separate strings.