pdk.util.String

functions to operate with strings

Functions


capitalize

Capitalizes a String changing the first character to title case. No other characters are changed. Example: String.capitalize('teST') will return 'TeST'.

Arguments:

Result:

Possible exceptions


concat

Concatenates the second defined string to the end of the first defined string.

Arguments:

Result:

  • output :: pdk.core.String - represents the concatenation of the first argument string followed by the second string argument's characters.

Possible exceptions


contains

Returns true if and only if the first defined string contains the second defined string.

Arguments:

Result:

  • output :: pdk.core.Boolean - true if the first argument String contains the second argument String, false otherwise.

Possible exceptions


countMatches

Counts how many times the substring appears in the larger string.

Arguments:

Result:

  • output :: pdk.core.Integer - the number of occurrences, 0 if either String is null.


difference

Compares two Strings, and returns the portion where they differ. More precisely, return the remainder of the second String, starting from where it's different from the first. This means that the difference between 'abc' and 'ab' is the empty String and not 'c'.

Examples:

  • String.difference('abcde', 'abcfgh xyz')='fgh xyz'

  • String.difference('test', 'test some')=' some'

Arguments:

Result:

  • output :: pdk.core.String - the portion of the second String where it differs from the first one; returns the empty String if they are equal.


endsWith

Tests if this string ends with the specified suffix.

Arguments:

Result:

  • output :: pdk.core.Boolean - true if the character sequence represented by the second argument is a suffix of the character sequence represented by the first argument; false otherwise. Note that the result will be true if the second argument is the empty string or is equal to the first argument.

Possible exceptions


equalsIgnoreCase

Compares this String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.

Arguments:

Result:

  • output :: pdk.core.Boolean - true if the arguments are not null and they are equivalent ignoring case; false otherwise.

Possible exceptions


getCommonPrefix

Compares all Strings in an array and returns the initial sequence of characters that is common to all of them.

Example:

A - Array that contains strings 'abcde' and 'abcfg'.

String.getCommonPrefix(A) = 'abc'.

Arguments:

Result:

  • output :: pdk.core.String - the initial sequence of characters that are common to all Strings in the array; empty String if the array is null, the elements are all null or if there is no common prefix.

Possible exceptions


indexOf

Returns the index within this string of the first occurrence of the specified string.

Arguments:

Result:

  • output :: pdk.core.Integer - the index of the first occurrence of the second argument in the first argument, or -1 if the string does not occur.

Possible exceptions


indexOfDifference

Compares all Strings in an array and returns the index at which the CharSequences begin to differ. Examples:

  • A - The array that contains strings: 'abc', 'abd', 'ae'. String.indexOfDifference(A)=1

  • A - The array that contains strings: 'abc', 'abd', 'abe'. String.indexOfDifference(A)=2

Arguments:

Result:

  • output :: pdk.core.Integer - the index where the strings begin to differ; -1 if they are all equal.


indexOfWithFrom

Returns the index within this string of the first occurrence of the specified string, starting the search at the specified index.

Arguments:

Result:

  • output :: pdk.core.Integer - the index of the first occurrence of the second argument in the first argument that is greater than or equal to starting index, or -1 if the search string does not occur.

Possible exceptions


isEmpty

Returns true if, and only if, length is 0.

Arguments:

Result:

Possible exceptions


isNumber

Checks if the String contains only Unicode digits. A decimal point is not a Unicode digit and returns false. null will return false. An empty String (length=0) will return false.

Example:

  • String.isNumeric(null)=false

  • String.isNumeric('123')=true

  • String.isNumeric('12.3')=false

  • String.isNumeric('-123')=false

Arguments:

Result:


join

Joins the elements of the provided array into a single String containing the provided list of elements. No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.

Arguments:

Result:


lastIndexOf

Returns the index within this string of the last occurrence of the specified string.

Arguments:

Result:

  • output :: pdk.core.Integer - the index of the last occurrence of the second argument in the first argument, or -1 if the search string does not occur.

Possible exceptions


lastIndexOfWithFrom

Returns the index within the first argument string of the last occurrence of the second argument string, searching backward starting at the specified index.

Arguments:

  • input :: pdk.core.String - the source string

  • toFind :: pdk.core.String - the search string.

  • fromIndex :: pdk.core.Integer - the index to start the search from. There is no restriction on the value of fromIndex. If it is greater than or equal to the length of the source string, it has the same effect as if it were equal to one less than the length of the source string: the second argument string may be searched. If it is negative, it has the same effect as if it were -1: -1 is returned.

Result:

  • output :: pdk.core.Integer - the index of the last occurrence of the second argument in the first argument, or -1 if the search string does not occur.

Possible exceptions


length

Returns the length of the string.

Arguments:

Result:

Possible exceptions


matches

Tells whether or not this string matches the given regular expression.

Arguments:

Result:

  • output :: pdk.core.Boolean - true if, and only if, the first argument string matches the given regular expression.

Possible exceptions


replace

Returns a new string resulting from replacing all occurrences of oldString in this string with newString.

Arguments:

Result:

  • output :: pdk.core.String - a string derived from first argument String by replacing every occurrence of the second argument string with the third argument string.

Possible exceptions


replaceFirst

Replaces the first substring of this string that matches the given regular expression with the given replacement.

Arguments:

Result:

Possible exceptions


replaceAll

Replaces each substring of this string that matches the given regular expression with the given replacement.

Arguments:

Result:

Possible exceptions


repeat

Returns a string whose value is the concatenation of this string repeated count times. If this string is empty or count is zero then the empty string is returned.

Arguments:

Result:

  • output :: pdk.core.String - string composed of this string repeated count times or the empty string if this string is empty or count is zero.

Possible exceptions


reverse

Reverses a String.

Arguments:

Result:

  • output :: pdk.core.String - the reversed String, null if null String input.


split

Splits this string around matches of the given regular expression.

Arguments:

Result:

  • output :: pdk.core.Array<pdk.core.String> - the array of strings computed by splitting the source string around matches of the given regular expression.

Possible exceptions


startWith

Tests if this string starts with the specified suffix.

Arguments:

Result:

  • output :: pdk.core.Boolean - true if the character sequence represented by the second argument is a prefix of the character sequence represented by the first argument string; false otherwise. Note also that true will be returned if the prefix string is an empty string or is equal to the source string.

Possible exceptions


substringTillEnd

Returns a new string that is a substring of this string from start index till the end.

Arguments:

Result:

Possible exceptions


substring

Returns a new string that is a substring of this string.

Arguments:

Result:

Possible exceptions


symbolAt

Returns the character at the specified index.

Arguments:

Result:

  • output :: pdk.core.String - the char value at the specified index of this string. The first char value is at index 0.

Possible exceptions


toLowerCase

Converts all of the characters in this String to lower case.

Arguments:

Result:

Possible exceptions


toUpperCase

Converts all of the characters in this String to uppercase.

Arguments:

Result:

Possible exceptions


trim

Returns a copy of the string, with leading and trailing whitespace omitted.

Arguments:

Result:

  • output :: pdk.core.String - a copy of the source string with leading and trailing white space removed, or this string if it has no leading or trailing white space.

Possible exceptions


uncapitalize

Uncapitalizes a String, changing the first character to lower case as per Character.toLowerCase(int). No other characters are changed.

Example:

String.uncapitalize('TeST') will return 'teST'.

Arguments:

Result:

  • output :: pdk.core.String - the uncapitalized String, null if null String input.


wrap

Wraps a String with another String.

Example:

String.wrap('some', 'x')='xsomex'

Arguments:

Result:

Possible exceptions

Last updated