Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this Page

...

String Functions and Properties

...

camelCase

Description

Returns the string in camel casecamelCase.

This is similar to the Lodash camelCase.

Syntax


Code Block
string.camelCase()


Example

Expression: $tag.camelCase()

where $tag is "sim_world"

Result: simWorld

...

Description

Returns the index within the calling String object of the first occurrence of the specified value where indexOf will search the searchValue from the 'fromIndex' of string to the end. The index of the first character is 0; -1 returns if the searchValue is not found.

This is similar to the JavaScript indexOf.

Syntax


Code Block
string.indexOf(searchValue[, fromIndex]) 


Example

Expression: $city.indexOf("San")

where $city is "San Francisco"

Result: 0


Expression: $city.indexOf("Jose", 0)

where $city is "San Jose"

Result: 4

...

kebabCase

Description

Returns the string in kebab casekebabCase.

This is similar to the Lodash kebabCase.

Syntax


Code Block
string.kebabCase()


Example

Expression: $action.kebabCase()

where $action is "Check_in"

Result: check-in

...

Description

Returns a new string with some or all matches of a pattern replaced by another.  The replacement can be a string or a function that is called for each match.

If the first argument is a regular expression, the method will replace all matches if the global flag is set (e.g. /test/g).  If the global flag is not set or the first argument is a string, only the first match will be replaced.

If the replacement is a function, its result will be used as the replacement for a given match.  The function will be passed the following parameters:

  • match - The : The substring that was matched by the regular expression.
  • p1, p2, ... - : The substrings that were captured by the regular expression.
  • offset: - The offset of this match within the original string.
  • string: - The original string being replaced.

This is similar to the JavaScript replace.

Syntax


Code Block
string.replace(find,replaceWith)


Example


Expression: $msg.replace ("l","x")

where $msg contains "Hello, World"

Result: Hexlo, World


To ignore case, use the /i flag:

Expression: $msg.replace (/world/i,"my friend")

where $msg contains "Hello, World"

Result: Hello, my friend


To globally replace all instances of the letter "l", use the /g flag:

Expression: $msg.replace (/l/g,"x")

where $msg contains "Hello World"

Result: Hexxo Worxd


Expression: $inputstring.replace (/\//g,"_")

where $inputstring contains "/org/projectspace/project"

Result:  _org_projectspace_project

To pass a callback function for matching strings in the regex A-Z

Expression: $value.replace (/ABC/g,"123")

where $value contains "/org/projectspace/project"

Result:  _org_projectspace_project


To capitalize the words in a string:

Expression: $msg.replace(/\b([a-z])(\w+)\b/g, (_matched, first, rest) => first.toUpperCase() + rest.toLowerCase())

where $msg contains "hello, world!"

Result: Hello, World!


...

Description

Returns a new string with text extracted from another string.

If beginIndex is greater than or equal to the length of the string, an empty string is returned. If it is negative, it returns that many characters from the end of the string length.

If endIndex is omitted, slice() extracts to the end of the string. If it is a positive value, the string value is captured up to, but not including that character. If the value is negative, the capture extracts to that number of characters from the end.

This is similar to the JavaScript slice.

Syntax


Code Block
string.slice(beginIndex[, endIndex])

Example

Where $String contains "Copyright 2017 All rights reserved."

Expression: $String.slice(10)

Result: 2017 All rights reserved.


Expression: $String.slice(10,14)

Result: 2017


Expression: $String.slice(10,-2)

Result: 2017 All rights reserve


Expression: $String.slice(-2)

Result: d.

...


snakeCase

Description

Returns the string in snake casesnakeCase.

This is similar to the Lodash snake case.

Syntax


Code Block
string.snakeCase()


Example

Expression: $category.snakeCase()

where $category is "LevelCritical"

Result: level_critical

...

Description

Returns the value of the string converted to lowercaselower case.

This is similar to the JavaScript toLowerCase.

Syntax


Code Block
string.toLowerCase()


Example

Expression: $login.toLowerCase()

where $login contains FirstLast@email.com.

Result: firstlast@email.com

...

Expand
titleChecking for a Non-empty String

Checking for a Non-empty String

Expression


Code Block
$customer.lastname.trim() || 'default'


DescriptionThe expression verifies if $customer.lastname and $customer.lastname.trim() has a value. If it does, then the value of $customer.lastname.trim() is applied to the target path; otherwise, otherwise 'default' gets applied to the target path.


...

Expand
titleChecking for an Existing Value

Checking for an Existing Value

Expression


Code Block
$.hasOwnProperty('customer.lastname') || 'default'


DescriptionThe expression verifies if $customer.lastname exists in the input document. If  If it does, then it the expression applies its value to the target path; otherwise, otherwise it applies 'default' of the input document to the target path.



Expand
titleChecking for a Non-empty String and an Existing Value

Checking for a Non-empty String and an Existing Value

Expression


Code Block
($.hasOwnProperty('customer.lastname') && $customer.lastname.trim()) || 'default''


DescriptionThe expression verifies if a property exists in the input document and if $customer.lastname and $customer.lastname.trim() provide a value. If it does, then it the expression applies its value to the target path; otherwise, otherwise it applies 'default' of the input document to the target path.



Expand
titleCreating an Email Address from First Initial, Last Name

Creating an Email Address from First Initial, Last Name

Expression


Code Block
$first_name.substr(0,1).toLowerCase()+$last_name.toLowerCase() + "@example.com"


Code Block
$first_name.charAt(0).toLowerCase()+$last_name.toLowerCase() + "@example.com"


DescriptionEither expression grabs the first letter of the $first_name field, converts it to lowercaselower case, then adds it to the $last_name value and appends "@example.com" before writing it to $Email.


...