length Method

Class: String

Description

This method returns the length of a string.

This method replaces the $LENGTH() function.

Syntax

StringObject.length(String delimiter)

Parameters

delimiter

The delimiter used to count subfields.

Returns

A Number.

When Became Available

v7.0

Example

type String STR = "in Maine it's raining cats and dogs"

 

type Number LEN = STR.length()     // 35

 

// (almost) NEVER the same as the previous example

type Number ZERO = STR.length("")  // 0

 

// number of words in this sentence ("it's" is single word)

type Number WORDS = STR.length(" ") // 7

 

// using a multi-character delimiter

type Number INS = STR.length("in")  // 5