Cloud Software Group, Inc. EBX®
Documentation > Developer Guide > EBX® Script > API
Navigation mode Documentation > Developer Guide > EBX® Script > API

# Unit core.string

Script unit that provides string manipulation functions.

Methods
function capitalize(str: string): string Capitalizes a String changing the first character to title case as per Character.
function contains(value: string, searchString: string): boolean Returns true if a value string contains a searchString.
function endsWith(value: string, suffix: string): boolean Returns true if a value string ends with a suffix.
function format(format: string, args: string[]): string Returns a formatted string using the specified format string and arguments.
function formatWithLocale(format: string, args: string[]): string Returns a formatted string using the specified format string and arguments in the specified Locale.
function indexOf(str: string, searchStr: string): number Finds the first index within a String, handling null.
function indexOfFromIndex(str: string, searchStr: string, fromIndex: number): number Finds the first index within a String, starting from a specified index, handling null.
function isAlphanumeric(str: string): boolean Checks if a String is alphanumeric.
function isBlank(str: string): boolean Checks if a String is empty (""), null, or whitespace only.
function isEmpty(value: string): boolean Returns true if value is null or a zero length string.
function isNumeric(str: string): boolean Checks if the String contains only Unicode digits.
function join(separator: string [, substring: string]...): string Returns a new string compose of all input substrings separated by as separator string.
function lastIndexOf(str: string, searchStr: string): number Returns the index within a string of the rightmost occurrence of the specified substring.
function lastIndexOfFromIndex(str: string, searchStr: string, fromIndex: number): number returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.
function replaceAll(value: string, pattern: string, replacement: string): string Returns a new string with all pattern occurrences in input value string replaced with replacement.
function replaceFirst(value: string, pattern: string, replacement: string): string Returns a new string with the first pattern occurrence in input value string replaced with replacement.
function reverse(str: string): string Reverses a String.
function right(value: string, index: decimal): string Returns a new string that contains the right characters from value string.
function split(str: string): string[] Splits the provided text into an array, using whitespace as the separator.
function split(str: string, separator: string): string[] Splits the provided text into an array, with the specified separator.
function startsWith(value: string, prefix: string): boolean Returns true if a value string starts with a prefix.
function substring(value: string, startIndex: decimal, endIndex: decimal): string Returns a new string that contains a subsequence of characters from value string.
function toLowerCase(value: string): string Returns a new string with all characters from input value string to lower case.
function toUpperCase(value: string): string Returns a new string with all characters from input value string to upper case.
function trim(str: string): string Removes control characters (char <= 32) from both ends of this String, handling null by returning null.
function valueOf(obj: Object): string Returns the string representation of the Object argument.

## capitalize

function capitalize(str: string): string

Capitalizes a String changing the first character to title case as per Character.toTitleCase(Number).

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.capitalize('hello'); // "Hello"
      var result2 := s.capitalize('hello world'); // "Hello world"
      var result3 := s.capitalize(''); // ""
      var result4 := s.capitalize(null); // null
      ...
    end

Parameters :

str The input string

Return :

The capitalized string

Can be used in: Script tasks, Table triggers, Function fields

## contains

function contains(value: string, searchString: string): boolean

Returns true if a value string contains a searchString.

Parameters :

value: the input string

searchString: the input searchString to look for

Return :

true if value contains the searchString or else false.

Returns null if any parameters is null.

Can be used in: Script tasks, Table triggers, Function fields

## endsWith

function endsWith(value: string, suffix: string): boolean

Returns true if a value string ends with a suffix.

Parameters :

value: the input string

prefix: the input suffix to look for

Return :

true if value ends with suffix or else false.

Returns null if any parameters is null.

Can be used in: Script tasks, Table triggers, Function fields

## format

function format(format: string, args: string[]): string

Returns a formatted string using the specified format string and arguments. this will use Locale.US

Example:

    uses core.string as s;
    uses core.locale as l;
    procedure doSomething()
    begin
      var result := s.format(l.fromString(en-US), 'Hello, %s!', 'world'); // 'Hello, world!'
      var result2 := s.format(l.fromString(en-US),'The value is %.2f', 3.14159); // 'The value is 3.14'
      var result2 := s.format(l.fromString(fr-FR),'The value is %.2f', 3.14159); // 'The value is 3.14'
      var result3 := s.format(l.fromString(en-US), null); // null
      var result4 := s.format(l.fromString(en-US), 'No arguments'); // 'No arguments'
      ...
    end

Parameters :

format The format string

args Arguments referenced by the format specifiers in the format string

Return :

The formatted string

Can be used in: Script tasks, Table triggers, Function fields

## formatWithLocale

function formatWithLocale(format: string, args: string[]): string

Returns a formatted string using the specified format string and arguments in the specified Locale.

Example:

    uses core.string as s;
    uses core.locale as l;
    procedure doSomething()
    begin
      var result := s.formatWithLocale(l.fromString(en-US), 'Hello, %s!', 'world'); // 'Hello, world!'
      var result2 := s.formatWithLocale(l.fromString(en-US),'The value is %.2f', 3.14159); // 'The value is 3.14'
      var result2 := s.formatWithLocale(l.fromString(fr-FR),'The value is %.2f', 3.14159); // 'The value is 3.14'
      var result3 := s.formatWithLocale(l.fromString(en-US), null); // null
      var result4 := s.formatWithLocale(l.fromString(en-US), 'No arguments'); // 'No arguments'
      ...
    end

Parameters :

local the local used for formatting

format The format string

args Arguments referenced by the format specifiers in the format string

Return :

The formatted string

Can be used in: Script tasks, Table triggers, Function fields

## indexOf

function indexOf(str: string, searchStr: string): number

Finds the first index within a String, handling null.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.indexOf('hello', 'e'); // 1
      var result2 := s.indexOf('hello', 'z'); // -1
      var result3 := s.indexOf(null, 'e'); // -1
      ...
    end

Parameters :

str The input string

searchStr The substring to search for

Return :

The index of the first occurrence of the substring within the string, or -1 if not found

Can be used in: Script tasks, Table triggers, Function fields

## indexOfFromIndex

function indexOfFromIndex(str: string, searchStr: string, fromIndex: number): number

Finds the first index within a String, starting from a specified index, handling null.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.indexOfFromIndex('hello', 'e', 0); // 1
      var result2 := s.indexOfFromIndex('hello', 'z', 0); // -1
      var result3 := s.indexOfFromIndex(null, 'e', 0); // -1
      ...
    end

Parameters :

str The input string

searchStr The substring to search for

fromIndex The index to start the search from

Return :

The index of the first occurrence of the substring within the string, or -1 if not found

Can be used in: Script tasks, Table triggers, Function fields

## isAlphanumeric

function isAlphanumeric(str: string): boolean

Checks if a String is alphanumeric.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.isAlphanumeric("hello123"); // true
      var result2 := s.isAlphanumeric("123"); // true
      var result3 := s.isAlphanumeric("hello"); // true
      var result4 := s.isAlphanumeric(null); // false
      ...
    end

Parameters :

str The input string

Return :

true if the string is alphanumeric, false otherwise

Can be used in: Script tasks, Table triggers, Function fields

## isBlank

function isBlank(str: string): boolean

Checks if a String is empty (""), null, or whitespace only.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.isBlank(''); // true
      var result2 := s.isBlank('   '); // true
      var result3 := s.isBlank(null); // true
      var result4 := s.isBlank('abc'); // false
      ...
    end

Parameters :

str The input string

Return :

true if the string is empty, null, or whitespace only, false otherwise

Can be used in: Script tasks, Table triggers, Function fields

## isEmpty

function isEmpty(value: string): boolean

Returns true if value is null or a zero length string.

Parameters :

value: a string value.

Return :

true if value is null or a zero length string, or else false. Never returns null.

Can be used in: Script tasks, Table triggers, Function fields

## isNumeric

function isNumeric(str: string): boolean

Checks if the String contains only Unicode digits. Note that the method does not allow for a leading sign, either positive or negative.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.isNumeric('12345'); // true
      var result2 := s.isNumeric('-12345'); // false
      var result3 := s.isNumeric('12.345'); // false
      var result4 := s.isNumeric(null); // false
      ...
    end

Parameters :

str The input string

Return :

true if the string contains only Unicode digits, false otherwise

Can be used in: Script tasks, Table triggers, Function fields

## join

function join(separator: string [, substring: string]...): string

Returns a new string compose of all input substrings separated by as separator string.

Parameters :

separator: the input separator string

substring: a substring to add to the result string. All element must be string.

Return :

a new string compose of all input substrings separated by the separator input.

If any parameters is null or no substrings is provided return null.

Can be used in: Script tasks, Table triggers, Function fields

## lastIndexOf

function lastIndexOf(str: string, searchStr: string): number

Returns the index within a string of the rightmost occurrence of the specified substring. The rightmost empty string "" is considered to occur at the index value str.length().

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.lastIndexOf('hello', 'o'); // 4
      var result2 := s.lastIndexOf('hello', 'z'); // -1
      var result3 := s.lastIndexOf(null, 'e'); // -1
      ...
    end

Parameters :

str The input string

searchStr The substring to search for

Return :

The index of the last occurrence of the substring within the string, or -1 if not found

Can be used in: Script tasks, Table triggers, Function fields

## lastIndexOfFromIndex

function lastIndexOfFromIndex(str: string, searchStr: string, fromIndex: number): number

returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.lastIndexOfFromIndex('hello', 'o', 3); // 4
      var result2 := s.lastIndexOfFromIndex('hello', 'o', 2); // 4
      var result3 := s.lastIndexOfFromIndex('hello', 'o', 0); // -1
      ...
    end

Parameters :

str The input string

searchStr The substring to search for

fromIndex The index to start the search from

Return :

The index of the last occurrence of the substring within the string, or -1 if not found

Can be used in: Script tasks, Table triggers, Function fields

## replaceAll

function replaceAll(value: string, pattern: string, replacement: string): string

Returns a new string with all pattern occurrences in input value string replaced with replacement.

Parameters :

value: the input string

pattern: the string pattern (regex) to replace

replacement: the replacement string

Return :

the new string or null if parameter is null.

Can be used in: Script tasks, Table triggers, Function fields

## replaceFirst

function replaceFirst(value: string, pattern: string, replacement: string): string

Returns a new string with the first pattern occurrence in input value string replaced with replacement.

Parameters :

value: the input string

pattern: the string pattern (regex) to replace

replacement: the replacement string

Return :

the new string or null if parameter is null.

Can be used in: Script tasks, Table triggers, Function fields

## reverse

function reverse(str: string): string

Reverses a String.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.reverse('hello'); // "olleh"
      var result2 := s.reverse(''); // ''
      var result3 := s.reverse(null); // null
      ...
    end

Parameters :

str The input string

Return :

The reversed string

Can be used in: Script tasks, Table triggers, Function fields

## right

function right(value: string, index: decimal): string

Returns a new string that contains the right characters from value string.

The staring starts from the specified index and extends to the end of the string.

Parameters :

value: the input string

index: the input start index (inclusive). Must be an integer greater or equal to zero and less or equal than the length of the string

Return :

the new string or null if any parameter is null.

Can be used in: Script tasks, Table triggers, Function fields

## split

function split(str: string): string[]

Splits the provided text into an array, using whitespace as the separator.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.split('hello world'); // ['hello', 'world']
      var result2 := s.split(''); // ['']
      var result3 := s.split(null); // null
      ...
    end

Parameters :

str The input string

Return :

An array of substrings

Can be used in: Script tasks, Table triggers, Function fields

## splitWith

function split(str: string, separator: string): string[]

Splits the provided text into an array, with the specified separator.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.split('hello,world', ','); // ['hello', 'world']
      var result2 := s.split('hello world', ' '); // ['hello', 'world']
      var result3 := s.split('', ' '); // ['']
      var result4 := s.split(null, ' '); // null
      ...
    end

Parameters :

str The input string

separator The separator string

Return :

An array of substrings

Can be used in: Script tasks, Table triggers, Function fields

## startsWith

function startsWith(value: string, prefix: string): boolean

Returns true if a value string starts with a prefix.

Parameters :

value: the input string

prefix: the input prefix to look for

Return :

true if value starts with prefix or else false.

Returns null if any parameters is null.

Can be used in: Script tasks, Table triggers, Function fields

## substring

function substring(value: string, startIndex: decimal, endIndex: decimal): string

Returns a new string that contains a subsequence of characters from value string.

The sub string start from the specified startIndex and extends to the endIndex of the input string.

Parameters :

value: the input string

startIndex: the input start index (inclusive). Must be an integer greater or equal to zero and less or equal than the length of the string.

endIndex: the input end index (exclusive). Must be an integer greater or equal to startIndex and less or equal than the length of the string.

Return :

the new string or null if any parameter is null.

Can be used in: Script tasks, Table triggers, Function fields

## toLowerCase

function toLowerCase(value: string): string

Returns a new string with all characters from input value string to lower case.

Parameters :

value: the input string

Return :

the lower cased string or null if parameter is null.

Can be used in: Script tasks, Table triggers, Function fields

## toUpperCase

function toUpperCase(value: string): string

Returns a new string with all characters from input value string to upper case.

Parameters :

value: the input string

Return :

the upper cased string or null if parameter is null.

Can be used in: Script tasks, Table triggers, Function fields

## trim

function trim(str: string): string

Removes control characters (char <= 32) from both ends of this String, handling null by returning null.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.trim('  hello  '); // "hello"
      var result2 := s.trim('   '); // ""
      var result3 := s.trim(null); // null
      ...
    end

Parameters :

str The input string

Return :

The trimmed string

Can be used in: Script tasks, Table triggers, Function fields

## valueOf

function valueOf(obj: Object): string

Returns the string representation of the Object argument.

Example:

    uses core.string as s;
    procedure doSomething()
    begin
      var result := s.valueOf('hello'); // 'hello'
      var result2 := s.valueOf(123); // '123'
      var result3 := s.valueOf(null); // null
      ...
    end

Parameters :

obj The object to convert to a string

Return :

The string representation of the object

Can be used in: Script tasks, Table triggers, Function fields

Documentation > Developer Guide > EBX® Script > API