Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Methods for string variables

Updated on October 19, 2022

The String variable provides a comprehensive selection of string manipulation and formatting methods.

Methods

MethodDescriptionParametersResult type
AppendModifies the value of the variable by adding a text string to the end of the value. String parameter. The string to append. String result. Contains the initial string variable value with the value of the string parameter appended.
ContainsComparison method. Returns a True/False value based on whether a particular character or sequence of characters is located within initial value of the variable. String parameter. The string to which the value of the string variable is compared. Boolean. True if string value and parameter are equivalent. False otherwise.
EndsWith

Returns a True/False value based on the match value. The method applies to the StringValue and evaluates the last characters of the string to the match string.

Here is an example:

If the StringValue is: "Aid of their party” and the match is "part” the result is false.

String - StringValue. The string to which the method is applied.

String - Match. The string to which the ending of the StringValue is compared.

Boolean. True if the parameter string is equivalent to the end of the StringValue.
Equals (2 overrides)

Use Equal to compare two strings and determine if they are equivalent. Accepts two strings as an input with another input being StringComparrison. Returns a Boolean value to show whether the strings are equivalent. You can choose from these values for StringComparrison:

CurrentCulture - Compare the strings using culture-sensitive sort rules and the current culture.

CurrentCultureIgnoreCase - Compare the strings using culture-sensitive sort rules and the current culture, while ignoring the case of the strings being compared.

InvariantCulture - Compare the strings using culture-sensitive sort rules and the invariant culture.

InvariantCultureIgnoreCase - Compare the strings using culture-sensitive sort rules and the invariant culture, while ignoring the case of the strings being compared.

Ordinal - Compare the strings using ordinal (binary) sort rules.

OrdinalIgnoreCase - Compare the strings using ordinal (binary) sort rules and ignore the case of the strings.

String - StringValue. The strings to be compared
Format (6 overrides)

Use this method to replace one or more placeholders in a string (FormatString) with a string value. You can include multiple placeholders. When you add a placeholder value, a new input is added to the bottom of the automation block so that another placeholder value can be entered.

Here is an example:

For StringValue0 = Studio,

StringValue1 = Joe Smith, and

StringValue2 = much.

FormatString: With {0} solutions, {1}'s

handle time {2} is lower.

Result: With Studio solutions, Joe Smith's handle time much is lower.

String - FormatString. The string that contains the text you want to format. String - Result is a string formatted as you indicated on the automation block.
IndexOf (2 parameters)Returns the index (position within the string) of the character supplied (Match). Note that the first position in the string has index 0. This method reads the String Value and returns the location of the first match.

StringValue. The string to which the method is applied.

Match - Character parameter. The parameter is matched against each character in the string starting at position 0.

Integer - Represents the position in the string at which the Match character is matched for the first time.
IndexOf (3 parameters)Returns the index (position within the string) of the character supplied (Match). The method searches for a match starting in the position indicated by StartIndex. Note that the first position in the string has index 0. This method reads the StringValue and returns the location of the first match found on or after the starting position.

StringValue. The string to which the method is applied.

Match - Character parameter for which the method searches.

StartIndex - Integer parameter which denotes the location from which the search begins.

Integer - Represents the position in the string at which the Match character is matched for the first time following the StartIndex.
IndexOf (4 parameters)Returns the index (position within the string) of the character supplied (Match). The method searches for a match starting in the position indicated by the Start Index and ending at the Count. Note that the first position in the string has index 0. This method reads the current StringValue and returns the location of the first match found on or after the starting position up to the ending position.

StringValue. The string to which the method is applied.

Match - Character parameter for which the method searches.

StartIndex - Integer parameter which denotes the location from which the search begins.

Count - Integer parameter which denotes the number of character positions, following the start index, which are to be searched.

Integer - Represents the position in the string at which the Match character is matched within a substring starting at the StartIndex through the Count value.
InsertThis method creates a new string which is a combination of the original StringValue plus the new text (NewValue) inserted at the specified position (StartIndex) in the string.

StringValue. The string to which the method is applied.

Integer - StartIndex. Position at which the newvalue parameter is inserted.

String - NewValue. The string to be inserted in the StringValue.

String. Result contains the original value of the StringValue and the value of the NewValue parameter inserted at the designated start index position parameter.
IsControlIndicates whether the string is categorized as a control.

String

Int32

Returns True if the string is a control
IsDbNullOrEmptyUse this method to see if a value is DBNull or empty. StringValue. The string to which the method is applied. Boolean. True result if the value is DBNull or empty.
IsDigitIndicates whether a string is categorized as a decimal digit. StringReturns True if value is a decimal digit
IsLetterIndicates whether the specified string is categorized as Unicode letters. StringReturns True for letters
IsLetteOrDigitIndicates whether a string is categorized as letters or decimal digits. StringReturns True for letters or decimal digits
IsLowerIndicates whether a string consists of lowercase letters. StringBoolean: Returns True for lowercase letters.
IsNullOrEmptyIndicates whether the specified string is null or an empty string (""). StringBoolean: Returns

True

if the string is null or empty
IsNumberIndicates whether the character at the specified position in a specified string is categorized as a number.

String

Int32

Boolean: Returns

True

if the string consists of numbers
IsPunctuationIndicates whether a string is categorized as a punctuation mark. StringBoolean: Returns True if the string consists of punctuation marks
IsRegexMatchThis method determines if the given Regex expression (Expression parameter) is matched within the StringValue.

StringValue. The string to which the method is applied.

String - Expression. The Regex expression for which a match is sought.

Boolean. True result if the Expression is matched in the StringValue.
IsSeparatorIndicates whether the string is categorized as a separator character.

String

Int32

Boolean: Returns

True

if the value is a separator
IsSymbolIndicates whether a string is categorized as symbol characters.

String

Int32

Boolean: Returns

True

if the string consists of symbols
IsUpperIndicates whether a string is categorized as an uppercase letter. StringBoolean: Returns

True

if the string consists of uppercase letters
IsWhiteSpaceIndicates whether a string consists of whitespace.StringBoolean: Returns

True

if the string consists of whitespace
Join (2 parameters)

This method reads the contents of a string array (val) and joins all of array items. By entering a sep value, you can insert a string or character at the places at which strings are joined.

For example, if the array contains the following:

  • abc
  • def
  • ghi

and you enter "-" as the sep value, the resulting string would be: abc-def-ghi.

The sep value can be omitted to have no separation indicators in the result string.

String - Sep. The "Sep” represents the character or string of characters that denotes the separation point of strings within the input array.

String array - Val. The source of string values to be joined.

String representing the concatenation of the array (val) strings and the separation identifier (sep).
Join (4 parameters)

This method reads the contents of a string array (val), beginning the item indicated by the First parameter and ending after the number of items indicated by the Count parameter. For the items from the First position and included in the Count, the method joins the array items. By entering a sep value, you can insert a string or character at the places at which strings are joined.

Note that the array contents are counted from 0 (the first item in the array is at location 0)

For example, if the array contains the following:

  • abc 0
  • def 1
  • ghi 2

    and you enter "-" as the sep value, 1 as the First and 2 as the count, the resulting string would be: def-ghi.

    The sep value can be omitted to have no separation indicators in the result string.

String - Sep parameter represents the character or string of characters that denotes the separation point of strings within the input array.

String array - Val. The source of string values to be joined.

Int - First. The index of the first item in the array to be joined.

Int - Count. The number of items, following the First, to be included in the Join.

String representing the concatenation of the array (val) strings and the separation identifier (sep) including only the items in the val array starting with the First position and ending at the First + Count position.
LastIndexOf (2 parameters)

This method returns the index of the last position at which the match string is found.

For example, given the string:

"The time has come”

And match value "me”

The result is: 15 as in "come”

StringValue. The string to which the method is applied.

String - match. The string for which the match is sought.

Int - Result is index number of the position at which the match string is located in the StringValue.
LastIndexOf (3 parameters)

This method returns the index of the last position at which the match string is found within a substring of the initial StringValue comprised of the characters from index 0 to the start index.

For example, if the string is:

"The time has come”

And the match value is "me”, given a startindex of 15 returns index position 6 (as in "time”).

StringValue. The string to which the method is applied.

String - match. The string for which the match is sought.

Int - startindex. The position in the string at which the search for the match ends.

Int - the index of the position in the StringValue at which the match is found.
LastIndexOf (4 parameters)

This method returns the index of the last position at which the match string is found within a substring of the initial stringValue comprised of the characters ending with the start index and of length "count”.

For example, if the string is: "The time has come”

And the match value is "e”, given a startindex of 10 and count of 10, returns index position 7 (as in "time”).

StringValue. The string to which the method is applied.

String - match. The string for which the match is sought.

Int - startindex. The position in the string at which the search for the match ends.

Count - The number of characters prior to the startindex from which the search substring is created.

Int - the index of the position in the StringValue at which the match is found.
PadLeft (2 parameters)This method right-aligns the characters in the string Value by inserting spaces in the beginning of the string (left) for the specified total width.

StringValue. The string to which the method is applied.

Int - totalwidth. Sets the width of the resulting string.

String result which is the original StringValue with spaces added to the beginning of the string and resulting in a string of the length specified (totalwidth).
PadRight (2 parameters)This method left-aligns the characters in the string Value by inserting spaces at the end of the string (right), for the specified total width.

StringValue. The string to which the method is applied.

Int - totalwidth. Sets the width of the resulting string.

String result which is the original StringValue with spaces added to the end of the string and resulting in a string of the length specified (totalwidth).
RegexReplace (3 parameters)

This method Replaces all occurrences of a character pattern defined by a regular expression (expression parameter) with a specified replacement character string (new value).

For example, for the string value: "For all good men.”

With this replacement expression: "good” and NewValue of "strong”, the result is:

"For all strong men.”

StringValue. The string to which the method is applied.

String - expression. The Regex string indicating the text in the StringValue to match.

String - NewValue. The text string to be inserted in the StringValue in the place of the matching string.

String - a new string in which the original StringValue has been modified such that the matching characters are replaced by the NewValue string.
RegexReplace (4 parameters)

This method replaces up to the specified number of occurrences (count) of a character pattern defined by a regular expression (expression parameter) with a specified replacement character string (new value).

For example, for the StringValue: "The time has come for all good men to come to the aid of their party.”

With this replacement expression: come, NewValue of gone, and count of 1, the result is:

"The time has gone for all good men to come to the aid of their party.”

StringValue. The string to which the method is applied.

String - expression. The Regex string indicating the text in the StringValue to match.

String - NewValue. The text string to be inserted in the StringValue in the place of the matching string.

Int - Count. The number of matching occurrences to be replaced.

String - a new string in which the original StringValue has been modified such that the matching characters are replaced by the NewValue string.
RegexReplace (5 parameters)

This method replaces up to the specified number of occurrences (count) of a character pattern defined by a regular expression (expression parameter) with a specified replacement character string (new value) starting at a specified character position in the input string.

For example, for the StringValue: "The time has come for all good men to come to the aid of their party.”

With this replacement expression: "come”, NewValue of "go”, and count of 1, and Startat value of 17 the result is:

"The time has come for all good men to go to the aid of their party.”

StringValue. The string to which the method is applied.

String - expression. The Regex string indicating the text in the StringValue to match.

String - NewValue. The text string to be inserted in the StringValue in the place of the matching string.

Int - Count. The number of matching occurrences to be replaced.

Int - Startat. The position in the string from which the replacements can be made.

String - a new string in which the original StringValue has been modified such that the matching characters are replaced by the NewValue string.
Remove (2 parameters)Deletes characters from the StringValue beginning at a specified position (startindex).

StringValue. The string to which the method is applied.

Int - StartIndex. The position within the string from which characters are deleted from the StringValue.

String - result is the StringValue after characters have been deleted.
Remove (3 parameters)Deletes a specified number of characters (count) from the StringValue beginning at a specified position (StartIndex).

StringValue. The string to which the method is applied.

Int - StartIndex. The position within the string from which characters are deleted from the StringValue.

Int - Count. The number of characters, beginning at the StartIndex, to delete.

String - result is the StringValue after characters have been deleted.
Replace (3 parameters)Replaces all occurrences of a specified string ( ) in the StringValue with another string ( ).

StringValue. The string to which the method is applied.

String - OldValue. The string to replace in the StringValue.

String - NewValue. The string to insert in the StringValue in all places where the OldValue is displayed.

String - result is a new string where the OldValue has been replaced with the NewValue.
ResetStateResets all component properties to their initial values.
Split (5 overrides)Creates a string array of substrings based on the StringValue and the count parameter. The substrings are delineated with a specified character (Delim parameter). The total number of array elements to create is specified in the count parameter.

StringValue. The string to which the method is applied.

Character/string - Delim. A character or string of characters which delineates substrings in the StringValue.

Int - Count. The total number of array elements to create from the StringValue.

A string array of elements comprised of the substrings from the StringValue.
StartsWithDetermines whether the beginning of the StringValue matches the specified string parameter (match).

StringValue. The string to which the method is applied.

String - match. The match parameter is a string to which the beginning of the StringValue is compared.

Boolean - result is True if the match parameter is identical to the beginning of the StringValue.
Substring (2 parameters)This method returns a substring from the StringValue beginning at the position indicated by the startIndex parameter.

StringValue. The string to which the method is applied.

Int - startIndex. The starting position in the StringValue at which the substring is retrieved.

String - result is a string retrieved from the StringValue beginning at the startIndex parameter and including all subsequent characters from the StringValue.
Substring (3 parameters)This method returns a substring from the StringValue beginning at the position indicated by the startIndex parameter and includes subsequent characters until the specified length (length parameter) is reached.

StringValue. The string to which the method is applied.

Int - startIndex. The starting position in the StringValue at which the substring is retrieved.

Int - length. The length of the substring to retrieve.

String - result is a string retrieved from the StringValue beginning at the start index and of a specified length.
ToLowerThis method returns the StringValue in lowercase characters. StringValue. The string to which the method is applied. String - equivalent to the StringValue comprised of all lowercase characters.
ToUpperThis method returns the StringValue in uppercase characters. StringValue. The string to which the method is applied. String - equivalent to the StringValue comprised of all uppercase characters.
TrimThis method returns the StringValue with any leading white spaces or trailing white spaces removed. StringValue. The string to which the method is applied. String - equivalent to the StringValue with all leading and trailing spaces removed.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us