String Actions
  • 03 Jun 2022
  • 3 Minutes to read
  • Dark
    Light

String Actions

  • Dark
    Light

Article Summary

String Actions

splitString

Split a string on a delimiter into an array of strings.

Property

Value

Description

string*

text, expression, variable

the original string

delimiter*

text, expression, variable

the delimiter pattern - may be a "string" or a /regex/

returnVariable

expression, variable

name of the variable to be assigned to the return value

result = splitString("713-555-1212","-")

stringContains

Check if a string contains a pattern.

Property

Value

Description

string*

text, expression, variable

the string to compare with

pattern*

text, expression, variable

the pattern to compare against - may be a "string" or a /regex/

ignoreCase

boolean, expression, variable

ignore case when comparing characters (default: false)

returnVariable

expression, variable

name of the variable to be assigned to the return value

containsNumber = stringContains("Sup3rD00per", "/\d/")

stringEndsWith

Check if a string ends with a pattern.

Property

Value

Description

string*

text, expression, variable

the string to compare with

pattern*

text, expression, variable

the pattern to compare against - may be a "string" or a /regex/

ignoreCase

boolean, expression, variable

ignore case when comparing characters (default: false)

returnVariable

expression, variable

name of the variable to be assigned to the return value

isLast4Digits = stringEndsWith("555-666-7777", "/\d{4}/")

stringEquals

Compare a string for equality.

Property

Value

Description

string*

text, expression, variable

the string to compare with

pattern*

text, expression, variable

the pattern to compare against - may be a "string" or a /regex/

ignoreCase

boolean, expression, variable

ignore case when comparing characters (default: false)

returnVariable

expression, variable

name of the variable to be assigned to the return value

isEmailAddress = stringEquals("jdoe@example.com", "/
[a-zA-Z]+@[a-zA-Z]+\.[a-zA-Z]{2,3}/")

stringEscape

Escape string(s).

Property

Value

Description

text*

text, expression, variable

a string, array , or record containing text to be escaped

method*

choice (ecmascript, html, java, ldap-dn, ldap-filter, sql, mysql, postgresql, url, xml), text, expression, variable

the escaping method

returnVariable

expression, variable

name of the variable to be assigned to the return value

name = user.sn + ", " + user.givenName
escapedName = stringEscape(name, "ldap-dn")
dn = "cn=" + escapedName + ",cn=users,dc=example,dc=com")

stringFromTemplate

Create a string from a template and arguments.

Property

Value

Description

format*

text, expression, variable

the template string containing %name% references to indexes/fields/properties in args

args*

expression, variable

an Array, Record, or Object containing arguments to be used by the format string

escapeMethod

choice (ecmascript, html, java, ldap-dn, ldap-filter, sql, mysql, postgresql, url, xml), text, expression, variable

the escaping method to apply to values from args

returnVariable

expression, variable

name of the variable to be assigned to the return value

name = user.sn + ", " + user.givenName
dn = stringFromTemplate("cn=%cn%,cn=users,dc=example,dc=com", {cn: name})

stringLength

Get the length of a string.

Property

Value

Description

string*

text, expression, variable

the string

returnVariable

expression, variable

name of the variable to be assigned to the return value

len = stringLength("jdoe@example.com")

stringRemoveDiacriticals

Remove diacriticals from characters in a string

Property

Value

Description

text*

text, expression, variable

a string

returnVariable

expression, variable

name of the variable to be assigned to the return value

# Should return "TestaaeeiioooouuuuAAEEIIOOOOUUUU"
s = stringRemoveDiacriticals("Testaáeéiíoóö?uúü?AÁEÉIÍOÓÖ?UÚÜ?")

stringRepeat

Return a new string with a specified number of copies of the original

Property

Value

Description

text*

text, expression, variable

a string

count*

expression, variable

number of times to repeat

returnVariable

expression, variable

name of the variable to be assigned to the return value

varIndentString = stringRepeat(" ", varIndentLevel * 4)

stringReplaceAll

Replace all instances of a pattern within a string.

Property

Value

Description

string*

text, expression, variable

the original string

pattern*

text, expression, variable

the pattern to replace - may be a "string" or a /regex/

replacement

text, expression, variable

the replacement string

ignoreCase

boolean, expression, variable

ignore case when comparing characters (default: false)

returnVariable

expression, variable

name of the variable to be assigned to the return value

phoneNumber = stringReplaceAll("713.555.1212",".","-")

stringReplaceFirst

Replace the first instance of a pattern within a string.

Property

Value

Description

string*

text, expression, variable

the original string

pattern*

text, expression, variable

the pattern to replace - may be a "string" or a /regex/

replacement

text, expression, variable

the replacement string

ignoreCase

boolean, expression, variable

ignore case when comparing characters (default: false)

returnVariable

expression, variable

name of the variable to be assigned to the return value

phoneNumber = stringReplaceFirst("713.555.1212",".","-")

stringStartsWith

Check if a string starts with a pattern.

Property

Value

Description

string*

text, expression, variable

the string to compare with

pattern*

text, expression, variable

the pattern to compare against - may be a "string" or a /regex/

ignoreCase

boolean, expression, variable

ignore case when comparing characters (default: false)

returnVariable

expression, variable

name of the variable to be assigned to the return value

startsWith3Digits = stringStartsWith("713.555.1212",/\d{3}/)

stringToLower

Convert a string to lower-case.

Property

Value

Description

string*

text, expression, variable

the string

returnVariable

expression, variable

name of the variable to be assigned to the return value

result = stringToLower("JDoe@Example.COM")

stringToUpper

Convert a string to upper-case.

Property

Value

Description

string*

text, expression, variable

the string

returnVariable

expression, variable

name of the variable to be assigned to the return value

result = stringToUpper("JDoe@Example.COM")

subString

Get a portion of a string.

Property

Value

Description

string*

text, expression, variable

the original string

startIndex*

expression, variable

the starting index (starting at 0) of the sub-string within the original string

length

expression, variable

the length of the sub-string within the original string (default: end of original string)

returnVariable

expression, variable

name of the variable to be assigned to the return value

guid = "{03265F05-6D90-4AC1-9A97-0A432ACA761A}"
# remove leading and trailing {}
result = subString(guid, 1, guid.length - 2)

toString

Get the string representation of a value.

Property

Value

Description

value*

text, expression, variable

the value

returnVariable

expression, variable

name of the variable to be assigned to the return value

# convert number to string
result = toString(5)

Was this article helpful?

What's Next