Versions Compared

Key

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

In this Page

...

Description

Returns true or false after determining if one string can be found within another. If position is specified, the search will begin there. Position defaults to 0.

This is similar to the JavaScript containsincludes.

Syntax


Code Block
$string.contains(searchString[, position])


Example

Expression: $msg.contains('Hello')

where $msg contains "Hello, World"

Result: true


To specify a position in the string where to start searching:

Expression: $msg.contains('Hello', 8)

where $msg contains "Hello, World"

Result: false (because "Hello" exists before that position)

...

Description

Returns true or false after determining if one string ends with the characters of another. Optional parameters include searchString and length, where searchString searches for a string of the length specified.  If unspecified, the default is the length of the string entered.

This is similar to the JavaScript endsWith.

Syntax


Code Block
string.endsWith()


Example

Expression: $email.endsWith("@example.com")

Result: true

Expression: $bootstrapping.endsWith(searchString[length, 13])

Result: true

...

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.


...