Text & Strings

Methods

(inner) abstract()

Abbreviates the contents of one or more fields by:

  • Selecting the most significant words in a body of text
  • Abbreviating common words
  • Dropping vowels from words
  • Removing unnecessary text or characters, such as mail headers or white space
To Do
  • this needs to be implemented
Throws:

method not implemented

Type
Error

(inner) abstractSimple(bodyFields) → {TextOrTextList}

Creates a short abstract of a text or rich text field. Simpler and more efficient than using @Abstract.

Parameters:
NameTypeDescription
bodyFieldsTextOrTextList

Any number of fields containing the text to abstract. May be text or rich text fields. If Notes/Domino cannot locate a field by name, it uses the string literal instead. Enclose each field name in quotes and separate multiple names with colons: "Sales":"Figures".

See
Returns:

Returns the first 100 characters or first 2 paragraphs of text, whichever is smaller. All newline and tab characters are converted into spaces, and all empty paragraphs (containing only a newline character) are ignored. If the parameter is a single field, a text value is returned. If the parameter is a list of field names, then a text list is returned with each list element containing the abstracted text of the corresponding field in the parameter list. If a field parameter is of an invalid type, or can't be found, the text returned is the string of the field parameter.

Type: 
TextOrTextList
Examples
// If the field "Verse" contains the rich text:
// "One bright day
// in the middle of
// the night"
rosettajs.Text.abstractSimple("Verse");  // returns "One bright day in the middle of"
// If the field "Critics" contains the rich text:
// "When asked to comment on the movie, the reviewer stated that it was one of the year's best, and certainly would find a place on many award lists."
rosettajs.Text.abstractSimple("Critics");  // returns "When asked to comment on the movie, the reviewer stated that it was one of the year's best, and cert"

(inner) asc(text)

Changes full-width (double-byte) English letters or katakana within a character string to half-width (single-byte) characters.

Parameters:
NameTypeDescription
text*

The text or a reference to a value that contains the text you want to change. If text does not contain any full-width letters, text is not changed.

See
To Do
  • this needs to be implemented
Throws:

method not implemented

Type
Error

(inner) ascii(text, optionopt) → {TextOrTextList}

Converts an LMBCS (Lotus Multi-Byte Character Set) string to an ASCII string.

Parameters:
NameTypeAttributesDescription
textTextOrTextList

An LMBCS string.

optionboolean<optional>

"ALLINRANGE" will return a null string ("") if any characters in the original string cannot be represented by ASCII codes 32 to 127.

See
Returns:

The original string, with each character converted to an ASCII-compliant character. Any character that can't be represented by ASCII codes 32 to 127 is replaced with a question mark (?). If you specify "ALLINRANGE" and there are characters that can't be represented by ASCII codes 32 to 127, returns a null string ("").

Type: 
TextOrTextList
Examples
rosettajs.Text.ascii( "Çüé" ); // returns Cue
// Returns a null string ("") since the last 2 characters can't be represented by ASCII codes 32 to 127
rosettajs.Text.ascii("Çü飥", "ALLINRANGE");
rosettajs.Text.ascii(["Çü飥", "Çüé", "Abc"]);  // returns ['Cue??', 'Cue', 'Abc']

(inner) bahtText(number)

Converts a number to text, using the ß (baht) currency format.

Parameters:
NameTypeDescription
numbernumber

A number you want to convert to text, or a reference to a value containing a number, or a formula that evaluates to a number.

See
To Do
  • this needs to be implemented
Throws:

method not implemented

Type
Error

(inner) begins(within_text, find_text) → {boolean}

Determines whether a particular substring is stored at the beginning of another string.

This function is case-sensitive. If the either parameter is a list, the function tests each element of the second parameter against each element of the first parameter and returns true if any match occurs.

Parameters:
NameTypeDescription
within_textstring

Any string.

find_textstring

The string you want to search for at the beginning of string.

See
Returns:

true if substring is contained within string, beginning from the first letter. Returns false if not. This function is case-sensitive. If the either parameter is a list, the function tests each element of the second parameter against each element of the first parameter and returns true if any match occurs.

Type: 
boolean
Examples
rosettajs.Text.begins('Miriam-McGovern','Miriam');  // returns true
rosettajs.Text.begins('Miriam-McGovern',['Abc','Miri']);  // returns true
rosettajs.Text.begins(['John Jones','Mary Hill'],['Mi', 'Pa']);  // returns false;

(inner) char(number) → {TextOrTextList}

Converts IBM Code Page 850 code number into the corresponding single character string.

Parameters:
NameTypeDescription
numberNumberOrNumberList

Any number between 0 and 255. Non-integer numbers are truncated to integers.If the parameter is a list, the function operates on each element of the list, and the return value is a list with the same number of elements.

See
Returns:

A single character that corresponds to codeNumber. and docs.oasis-open.org

Type: 
TextOrTextList
Examples
rosettajs.Text.char(65);   // returns "A"
rosettajs.Text.char(237);  // returns "Ý"
rosettajs.Text.char(253);  // returns "²"
rosettajs.Text.char([65, 157, 'invalid', 169]);  // returns ["A", "Ø", error.value, "®"];

(inner) clean(text) → {string}

Removes all non-printable characters from text.

Parameters:
NameTypeDescription
textstring

Any worksheet information from which you want to remove nonprintable characters.

See
Returns:

The text without the non-printable characters.

Type: 
string
Example
rosettajs.Text.clean(`${rosettajs.Text.char(9)}Monthly report${rosettajs.Text.char(10)}`); // Removes the nonprintable characters CHAR(9) and CHAR(10) from the text string

(inner) code(text) → {number}

Returns a numeric code for the first character in a text string.

Parameters:
NameTypeDescription
textstring

The text for which you want the code of the first character.

See
Returns:

The character code for the first character in text.

Type: 
number
Example
rosettajs.Text.code("A"); // Return 65

(inner) compare(textlist1, textlist2, optionsopt) → {Array.<number>}

Compares the alphabetic order of the elements in two lists pair-wise.

Parameters:
NameTypeAttributesDescription
textlist1Array.<string>

A list of strings to compare. If textlist1 is shorter than textlist2, the last element in textlist1 is repeated until it reaches the same length as textlist2.

textlist2Array.<string>

A list of strings to compare. If textlist2 is shorter than textlist1, the last element in textlist2 is repeated until it reaches the same length as textlist1.

optionsstring | Array.<string><optional>

You can use the following keywords to specify the compare options:

  • "ACCENTSENSITIVE"
  • "ACCENTINSENSITIVE"
  • "CASESENSITIVE"
  • "CASEINSENSITIVE"
  • "PITCHSENSITIVE"
  • "PITCHINSENSITIVE"

By default, the following keywords are used for the compare:

["CASESENSITIVE", "ACCENTSENSITIVE", "PITCHSENSITIVE"]
See
Returns:

Each element is the result of comparing the corresponding elements in the text lists, and is one of three values:

  • 0 if the elements in the two lists are equal.
  • -1 if the element in the first list is less than the element in the second list.
  • 1 if the element in the first list is greater than the element in the second list.
Type: 
Array.<number>
Examples
rosettajs.Text.compare("Boston", "boston", "CASESENSITIVE"); // Returns 1
// Compares a list to the value "N" and returns [-1, 1, -1, 0, 0]. Boston and Moscow result in -1 (less than N), Tokyo results in 1 (greater than N), and n and N result in 0 (equal to N).
rosettajs.Text.text(rosettajs.Text.compare(["Boston", "Tokyo", "Moscow", "N", "n"], "N", "CASEINSENSITIVE"));

(inner) concat(…items) → {string}

Joins several text items into one text item.

Parameters:
NameTypeAttributesDescription
itemsArray.<string><repeatable>

The items to join.

See
Returns:

The concatenated string.

Type: 
string
Example
rosettajs.Text.concat("The"," ","sun"," ","will"," ","come"," ","up"," ","tomorrow."); // Returns "The sun will come up tomorrow."

(inner) concatenate(…items) → {string}

Joins several text items into one text item.

Parameters:
NameTypeAttributesDescription
itemsArray.<string><repeatable>

The items to join.

See
Returns:

The concatenated string.

Type: 
string
Example
rosettajs.Text.concatenate("Tokyo", ", ", "Japan"); // Returns "Tokyo, Japan"

(inner) contains(within_text, find_text) → {boolean}

Determines whether a substring is stored within a string.

This function is case-sensitive. If either parameter is a list, the function returns true if any element of the first parameter contains any element of the second parameter.

Parameters:
NameTypeDescription
within_textTextOrTextList

The string(s) you want to search.

find_textTextOrTextList

The string(s) you want to search for in string.

See
Returns:

True if any substring is contained in one of the strings. False if no substrings are contained in any of the strings.

Type: 
boolean
Examples
rosettajs.Textcontains('Miriam-McGovern','iam');  // returns 1
rosettajs.Text.contains('Miriam-McGovern',['Abc','McG']);  // returns 1
rosettajs.Text.contains(['John Jones','Mary Hill'],['hi', 'Pa']);  // returns 0;

(inner) dollar(number, decimalsopt) → {string}

Converts a number to text, using the $ (dollar) currency format.

Parameters:
NameTypeAttributesDescription
numbernumber

A number, a reference to a value containing a number, or a formula that evaluates to a number.

decimalsnumber<optional>

Optional. The number of digits to the right of the decimal point. If this is negative, the number is rounded to the left of the decimal point. If you omit decimals, it is assumed to be 2.

See
Returns:

Text using currency format, with the decimals rounded to the number of places you specify.

Type: 
string
Example
rosettajs.Text.dollar(1234.567); // Returns "$1,234.57"

(inner) ends(within_text, find_text) → {boolean}

Determines if a substring is at the end of a string.

This function is case-sensitive. If the either parameter is a list, the function tests each element of the second parameter against each element of the first parameter and returns 1 if any match occurs.

Parameters:
NameTypeDescription
within_textTextOrTextList

Text or text string. Any string.

find_textTextOrTextList

Text or text string. The string you want to search for at the beginning of string.

See
Returns:

True indicates that the find_text is at the end of within_test. Otherwise false if not.

Type: 
boolean
Examples
rosettajs.Text.ends('Miriam-McGovern','McGovern');  // returns 1
rosettajs.Text.ends('Miriam-McGovern',['Abc','Vern']);  // returns 0
rosettajs.Text.ends(['John Jones','Mary Hill'],['Ma', 'Hill']);  // returns 1

(inner) exact(text1, text2)

Checks to see if two text values are identical.

Parameters:
NameTypeDescription
text1string

The first text string.

text2string

The second text string.

See
Returns:

True if the two values are identical. False if they are not identical.

Examples
rosettajs.Text.exact("A","A"); // Returns true
rosettajs.Text.exact("A","a"); // Returns false
rosettajs.Text.exact("1",1); // Returns true

(inner) fileDir(pathname) → {TextOrTextList}

Returns the directory portion of a path name, that is, the path name minus the file name.

Parameters:
NameTypeDescription
pathnameTextOrTextList

Path name of a file.

See
Returns:

The directory part of the path name.

Type: 
TextOrTextList
Examples
rosettajs.Text.fileDir("c:\\europe.dat"); // Returns "c:\"
rosettajs.Text.fileDir("c:\\market\\data\\europe.dat":"\\europe.dat"); // Returns "c:\" : "\"
rosettajs.fileDir("europe.dat"); // Returns Null

(inner) find(find_text, within_text, start_numopt) → {number|Error}

Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.

Parameters:
NameTypeAttributesDefaultDescription
find_textstring

The text you want to find.

within_textstring

The text containing the text you want to find.

start_numnumber<optional>
0

Specifies the character at which to start the search. The first character in within_text is character number 1. If you omit start_num, it is assumed to be 1.

See
Returns:

The number of the starting position or an error if the string was not found.

Type: 
number | Error
Examples
rosetta.Text.find("b","abcabc"); // Returns 2
rosetta.Text.find("b","abcabcabc",3); // Returns 5

(inner) fixed(number, decimals, no_commas) → {string}

Formats a number as text with a fixed number of decimals.

Parameters:
NameTypeDefaultDescription
numbernumber

The number you want to round and convert to text.

decimalsnumber2

Optional. The number of digits to the right of the decimal point.

no_commasbooleanfalse

Optional. A logical value that, if TRUE, prevents FIXED from including commas in the returned text.

See
Returns:

The string representation of the number

Type: 
string
Examples
rosettajs.Text.fixed(1234.567, 1); // Returns "1234.6"
rosettajs.Text.fixed(-1234.567, -1, true); // Returns "-1230"

(inner) isTime(value) → {boolean}

Indicates whether a value is a time-date (or a time-date list).

Parameters:
NameTypeDescription
value*

any value

See
Returns:

True if the value ia a time-date or a time-date list. Othewise false.

Type: 
boolean
Examples
rosettajs.Text.isTime("08/31/2002"); // Returns true
rosettajs.Text.isTime(123); // Returns false

(inner) left(text, param) → {TextOrTextList}

Searches a string from left to right and returns the leftmost characters of the string.

Parameters:
NameTypeDescription
textTextOrTextList

The string where you want to find the leftmost characters.

paramnumber | string
  • Number: The number of characters to return. If the number is 2, the first two characters of the string are returned; if the number is 5, the first five characters are returned, and so on. If the number is negative, the entire string is returned. If using Open Formula implementation, param must be a number and is optional with a default of 1.
  • String: A substring of stringToSearch. Left returns the characters to the left of subString. It finds subString by searching stringToSearch from left to right. A string is only valid for the Notes formula implementation and param is required.
See
Returns:

The leftmost characters in stringToSearch. The number of characters returned is determined by either numberOfChars or subString. Left returns "" if subString is not found in stringToSearch. and docs.oasis-open.org

Type: 
TextOrTextList
Examples
rosettajs.left('Sale Price', 4); // returns 'Sale'
rosettajs.left('Sweden', 'en'); // returns 'Swed'
rosettajs.left(['Sweden', 'England'], 2); // returns ['Sw', 'En']

(inner) leftBack(stringToSearch, param) → {string}

Searches a string from right to left and returns a substring.

Parameters:
NameTypeDescription
stringToSearchTextOrTextList

The string where you want to find the leftmost characters.

paramnumber

Counting from right to left, the number of characters to skip. All the characters to the left of that number of characters are returned. If the number is negative, the entire string is returned.

See
Returns:

Text or text list. The leftmost characters in stringToSearch. The number of characters returned is determined by either numToSkip or startString.

Type: 
string
Examples
rosettajs.Text.leftBack('Sale Price', 4); // returns 'Sale P'
rosettajs.Text.leftBack('Sweden', 'en'); // returns 'Swed'
rosettajs.Text.leftBack(['Sweden', 'England'], 2); // returns ['Swed', 'Engl']

(inner) len(text) → {number}

Returns the number of characters in a text string

Parameters:
NameTypeDescription
textstring

The text whose length you want to find. Spaces count as characters.

See
Returns:

The number of characters in text.

Type: 
number
Examples
rosetta.Text.len("Hi There"); // Returns 8
rosetta.Text.len(""); // Returns 0
rosetta.Text.len(55); // Returns 2. Number are automatically converted to strings.

(inner) length(text) → {NumberOrNumberList}

Returns the number of characters in a text string.

Parameters:
NameTypeDescription
textTextOrTextList

A single string with the length you want to find, or a list of strings.

See
Returns:

If the parameter is a text string, length returns the number of characters in the specified string, including spaces and punctuation. If the argument is a text list, length searches the list of strings and returns the number of characters in each string as a number list.

Type: 
NumberOrNumberList
Examples
rosettajs.Text.length('four'); // returns 4
rosettajs.Text.length('four', 'seven'); // returns [4, 5]
rosettajs.Text.length('four', 12); // returns [4, 0]

(inner) like(text, pattern, escapeopt) → {boolean}

Matches a string with a pattern. It is case-sensitive.

Parameters:
NameTypeAttributesDescription
textTextOrTextList

The value to be tested to see if it matches pattern.

patternTextOrTextList

The sequence of characters to search for within text. May also contain any of the wildcard characters listed as follows:

  • C where C is any character. Matches any single, non-special, character C.
  • _ (Underscore) Matches any single character.
  • % Matches any sequence of zero or more characters.
escapestring<optional>

A character to use before a wildcard character to indicate that it should be treated literally.

See
Returns:

True if the pattern matches the text. False if the pattern does not matches the text.

Type: 
boolean
Examples
// Return false. The underscore matches only a single character.
rosettajs.Text.like( "A big test", "A_test");
// Returns true because the match is true for one element of the first parameter.
rosettajs.Text.like( ["A big test", "A big exam"], "%test" );
// Returns true. The first percent matches "100." The "/%" matches the percent sign because "/" is specified as the escape character. The last percent matches "ement."
rosettajs.Text.like( "A 100% improvement", "A %/% improv%", "/" )

(inner) lower(text) → {string}

Converts text to lowercase.

Parameters:
NameTypeDescription
textstring

The text you want to convert to lowercase. LOWER does not change characters in text that are not letters.

See
Returns:

The lower case text.

Type: 
string
Example
rosetta.Text.lower("HELLObc7"); // Returns "hellobc7"

(inner) lowerCase(text) → {TextOrTextList}

Converts the uppercase letters in the specified string to lowercase.

Parameters:
NameTypeDescription
textTextOrTextList

The string you want to convert to lowercase.

See
Returns:

The string, converted to lowercase letters.

Type: 
TextOrTextList
Examples
rosettajs.Text.lowerCase('ABcd'); // returns 'abcd'
rosettajs.Text.lowerCase('ABcd', 'efGH'); // returns ['abcd', 'efgh']

(inner) matches(text, pattern) → {boolean}

Tests a string for a pattern string. Because the pattern string can contain a number of "wildcard" characters and logical symbols, you can test for complex character patterns.

Parameters:
NameTypeDescription
textTextOrTextList

The string you want to scan in quotes. You can also enter the field name of a field that contains the string you want to scan; do not surround the field name in quotes.

patternTextOrTextList

The pattern you want to scan for in string surrounded by quotation marks. May contain wildcard characters and symbols (see the following table). The following symbols require a preceding backslash unless the pattern is enclosed in braces { } as a set: ?, *, &, !, |, , +. The symbols require two preceding backslashes instead of one if the pattern is specified as a literal. This is because the backslash is an escape character in string literals, so "?" passes "?" to the matching engine, where it is treated as a wildcard, while "\?" passes "?" to the matching engine, where it is treated as a question mark character. The wildcard characters and symbols are as follows:

  • C Where C is any character. Matches any single, non-special character C (or c)
  • ? Matches any single character
    • Matches any string (any number of characters)
  • {ABC} Matches any character in set ABC
  • {A-FL-R} Matches any character in the sets A...F and L...R
  • +C Matches any number of occurrences of C (or c)
  • ! Complements logical meaning of the pattern (logical NOT)
  • | Performs logical OR of two patterns
  • & Performs logical AND of two patterns
See
Returns:

True if text contains the pattern. False if text does not contain the pattern.

Type: 
boolean
Examples
rosettajs.Text.matches("A big test", "a?????test"); // Returns true
rosettajs.Text.matches("A big test", "a?test"); // Returns false
// Throws error, "Value cannot be a letter" if input contains any lowercase or uppercase letter between A and Z
if(rosettajs.Text.matches(rosettajs.Text.text(input), "+{A-z}")) throw new Error("Value cannot be a letter");

(inner) mid(text, start_num, num_chars) → {string}

Returns a specific number of characters from a text string starting at the position you specify

Parameters:
NameTypeDescription
textstring

The text string containing the characters you want to extract.

start_numnumber

The position of the first character you want to extract in text. The first character in text has start_num 1, and so on.

num_charsnumber

Specifies the number of characters you want MID to return from text.

See
Returns:

The text from the starting position.

Type: 
string
Examples
rosettajs.Text.mid("123456789",5,3); // Returns "567"
rosettajs.Text.mid("123456789",20,3); // Returns "". If Start is beyond string, return empty string.

(inner) middle(text, start, end) → {TextOrTextList}

Returns any substring from the middle of a string. The middle is found by scanning the string from left to right, and parameters determine where the middle begins and ends.

Parameters:
NameTypeDescription
textTextOrTextList

Any string

startnumber | string

If a number, a character position in text that indicates where you want the middle to begin, always counting from left to right. The middle begins one character after the start.

If a string, a substring of text that indicates where you want the middle to begin, always counting from left to right. The middle begins one character after the end of start.

endnumber | string

If a number, the number of characters that you want in the middle. If end is negative, the middle starts at start and continues from right to left. If end is positive, the middle starts one character past start and continues from left to right.

If a string, a substring of text that indicates the end of the middle. Returns all the characters between start and end.

See
Returns:

The substring from the middle of text, which begins at the start you specify and ends at the end you specify, or after end characters have been reached.

Type: 
TextOrTextList
Examples
rosettajs.Text.middle('North Carolina', ' ', 3); // returns 'Car'
rosettajs.Text.middle('This is the text', 4, 'text); // returns ' is the '
rosettajs.Text.middle(["Hello world", "This is the time"], 0, " "); // returns ['Hello', 'This']

(inner) middleBack(text, start, end) → {TextOrTextList}

Returns any substring from the middle of a string. The middle is found by scanning the string from right to left, and parameters determine where the middle begins and ends.

Parameters:
NameTypeDescription
textTextOrTextList

Any string.

startnumber | string

If a number, a character position in text that indicates where you want the middle to begin, always counting from right to left. The middle begins one character after the start. Always add 1 to this number; the end of the string is marked by one non-visible character and must be counted in the offset.

If a string, a substring of text that indicates where you want the middle to begin, always counting from right to left. The middle begins one character after the end of start.

endnumber | string

If a number, The number of characters that you want in the middle. If end is negative, the middle starts at start and continues from right to left. If end is positive, the middle starts one character past start and continues from left to right.

If a string, a substring of string that indicates the end of the middle. Returns all the characters between start and end.

See
Returns:

The substring from the middle of string, which begins at the offset or startString you specify and ends at the endstring you specify, or after the numberchars have been reached.

Type: 
TextOrTextList
Examples
rosettajs.Text.middleBack('Fluid Flow', 0, 5); // returns 'Flow'
rosettajs.Text.middleBack('This is the text', 'text', 'is'); // returns ' the '
rosettajs.Text.middleBack(["Hello world", "This is the time"], 0, " "); // returns ["world", "time"]

(inner) narrow(text) → {TextOrTextList}

Converts full-pitch alphanumeric characters (double byte characters -- DBCS) in the specified string to half-pitch alphanumeric characters (single byte characters -- SBCS). This function works in Japanese, Korean, Simplified Chinese, and traditional Chinese environments. In the Japanese environment, this function can convert full-pitch Katakana as well.

Parameters:
NameTypeDescription
textTextOrTextList

The string that you want to convert to single byte characters.

See
Returns:

The string converted to single byte characters.

Type: 
TextOrTextList
Examples
rosettajs.Text.narrow("0123456789ABCDEFGHI"); // returns "0123456789ABCDEFGHI"
rosettajs.Text.narrow(["0123456789ABCDEFGHI", "アイウABCエオカㄱㄲㄳ"]); // returns ["0123456789ABCDEFGHI", "アイウABCエオカᄀᄁᆪ"]

(inner) newLine() → {string}

Returns a new line (carriage return) into a text string.

See
Returns:

The new line character

Type: 
string
Example
// Returns "Hi
// There"
var greeting = "Hi" + rosettajs.Text.newLine() + "There";

(inner) numberValue(text, decimal_separatoropt, group_separatoropt) → {number}

Converts text to number in a locale-independent manner.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to convert to a number.

decimal_separatorstring<optional>
"."

Optional. The character used to separate the integer and fractional part of the result.

group_separatorstring<optional>
","

Optional. The character used to separate groupings of numbers, such as thousands from hundreds and millions from thousands.

See
Returns:

The number represented by the text.

Type: 
number
Example
rosettajs.Text.numberValue("2.500,27",",","."); // Returns 2,500.27

(inner) proper(text) → {string}

Capitalizes the first letter in each word of a text value.

Parameters:
NameTypeDescription
textstring

Text enclosed in quotation marks, a formula that returns text, or a reference to a value containing the text you want to partially capitalize.

See
Returns:

The text with all words starting with a capital letter.

Type: 
string
Examples
rosettajs.Text.proper("hello there"); // Returns "Hello There"
rosettajs.Text.proper("HELLO.THERE"); // Returns "Hello.There". Words are separated by spaces, punctuation, etc.

(inner) properCase() → {TextOrTextList}

Converts the words in a string to proper-name capitalization: the first letter of each word becomes uppercase, all others become lowercase.

Parameters:
NameTypeDescription
text.TextOrTextList

The string you want to convert.

See
Returns:

The string, converted to proper-name capitalization.

Type: 
TextOrTextList
Examples
rosettajs.Text.properCase('a title case'); // returns 'A Title Case'
rosettajs.Text.properCase('a title case','is awaiting trial'); // returns ['A Title Case','Is Awaiting Trial']

(inner) repeat(text, number, maxcharopt) → {TextOrTextList}

Repeats a string a specified number of times.

Parameters:
NameTypeAttributesDescription
textTextOrTextList

The string you want to repeat.

numberNumber

The number of times you want to repeat string.

maxcharNumber<optional>

The maximum number of characters you want returned. Repeat truncates the result to this number.

See
Returns:

The string, repeated number times until numberchars (if specified) is reached.

Type: 
TextOrTextList
Examples
rosettajs.Text.repeat('multiple ', 3); // returns 'multiple multiple multiple '
rosettajs.Text.repeat(['multiple ', 'hits '], 3); // returns ['multiple multiple multiple ', 'hits hits hits ']
rosettajs.Text.repeat(['multiple ', 'hits '], 3, 10); // returns ['multiple m', 'hits hits ']

(inner) replace(old_text, start, length, new_text) → {string}

Replaces characters within text

Parameters:
NameTypeDescription
old_textstring

Text in which you want to replace some characters.

startnumber

The starting character position in old_text that you want REPLACE to replace with new_text.

lengthnumber

The number of characters in old_text that you want REPLACEB to replace with new_text.

new_textstring

The text that will replace characters in old_text.

See
Returns:

The text with the characters replaced.

Type: 
string
Example
rosettajs.Text.replace("123456789",5,3,"Q"); // Returns "1234Q89"

(inner) replaceSubstring(source, from, to) → {TextOrTextList}

Replaces specific words or phrases in a string with new words or phrases that you specify. Case sensitive.

Parameters:
NameTypeDescription
sourceTextOrTextList

The string whose contents you want to modify.

fromTextOrTextList

A list containing the words or phrases that you want to replace.

toTextOrTextList

A list containing the replacement words or phrases.

See
Returns:

The sourceList, with any values from fromList replaced by the corresponding value in toList. If none of the values in fromList matched the values in sourceList, then sourceList is returned unaltered.

Type: 
TextOrTextList
Examples
rosettajs.Text.replaceSubstring("I like apples", "like", "hate"); // returns 'I hate apples'
rosettajs.Text.replaceSubstring("I like apples", ["like", "apples"], ["hate", "peaches"]); // returns 'I hate peaches'
rosettajs.Text.replaceSubstring(["I like apples", "I like bananas"], ["like", "I"], ["hates", "He"]); // returns ["He hates apples", "He hates bananas"]

(inner) rept(text, number_times) → {string}

Repeats text a given number of times.

Parameters:
NameTypeDescription
textstring

The text you want to repeat.

number_timesnumber

A positive number specifying the number of times to repeat text.

See
Returns:

The string containing the repeating text.

Type: 
string
Examples
rosettajs.Text.rept("X",3); // Returns "XXX"
rosettajs.Text.rept("X",0); // Returns ""

(inner) right(text, param) → {TextOrTextList}

Returns the rightmost characters in the string. You can specify the number of rightmost characters you want returned, or you can indicate that you want all the characters following a specific substring.

Parameters:
NameTypeDescription
textTextOrTextList

The string whose rightmost characters you want to find.

paramnumber | string
  • Number: The number of characters to return. If the number is 2, the first two characters of the string are returned; if the number is 5, the first five characters are returned, and so on. If the number is negative, the entire string is returned. If using Open Formula implementation, param must be a number and is optional with a default of 1.
  • String: A substring of stringToSearch. Left returns the characters to the left of subString. It finds subString by searching stringToSearch from left to right. A string is only valid for the Notes formula implementation and param is required.
See
Returns:

The rightmost characters in stringToSearch. The number of characters returned is determined by param. Right returns "" if subString is not found in stringToSearch. and docs.oasis-open.org

Type: 
TextOrTextList
Examples
rosettajs.right('Sale Price', 5); // returns 'Price'
rosettajs.right('Lennard Wallace', " "); // returns 'Wallace'
rosettajs.right(['Lennard', 'Wallace'], 3); // returns ['ard', 'ace']

(inner) rightBack(text, param) → {TextOrTextList}

Returns the rightmost characters in a string.

Parameters:
NameTypeDescription
textTextOrTextList

The string whose rightmost characters you want to find.

paramnumber | string

If a number, counting from left to right, the number of characters to skip. All the characters following that number are returned.

If a string, A substring of text. Returns all the characters following param. It finds param by searching text from right to left.

See
Returns:

The rightmost characters in text. The number of characters returned is determined by param.

Type: 
TextOrTextList
Examples
rosettajs.Text.rightBack('Sale Price', 5); // returns 'Price'
rosettajs.Text.rightBack('Lennard Wallace', " "); // returns 'Wallace'
rosettajs.Text.rightBack(['Lennard', 'Wallace'], 3); // returns ['nard', 'lace']

(inner) search(find_text, within_text, start_numopt) → {number|Error}

Finds one text value within another (not case-sensitive)

Parameters:
NameTypeAttributesDescription
find_textstring

The text that you want to find.

within_textstring

The text in which you want to search for the value of the find_text argument.

start_numnumber<optional>

Optional. The character number in the within_text argument at which you want to start searching.

See
Returns:

The starting index of find_text in within_text or an Error if find_text is not found.

Type: 
number | Error
Examples
rosettajs.Text.search('e', 'Statements', 6); // Returns 7
rosettajs.Text.search('margin', 'Profit Margin'); // Returns 8

(inner) substitute(text, old_text, new_text, instance_numopt) → {string}

Substitutes new text for old text in a text string.

Parameters:
NameTypeAttributesDescription
textstring

The text or the reference to a value containing text for which you want to substitute characters.

old_textstring

The text you want to replace.

new_textstring

The text you want to replace old_text with.

instance_numnumber<optional>

Optional. Specifies which occurrence of old_text you want to replace with new_text. If you specify instance_num, only that instance of old_text is replaced. Otherwise, every occurrence of old_text in text is changed to new_text.

See
Returns:

The string with the substituted text.

Type: 
string
Examples
rosettajs.Text.substitute("121212","2","ab"); // Returns "1ab1ab1ab"
rosettajs.Text.substitute("121212","2","ab",2); // Returns "121ab12"
rosettajs.Text.substitute("Hello","x","ab"); // If not found, returns unchanged

(inner) t(value) → {string}

Return the text (if text), else return 0-length Text value

Parameters:
NameTypeDescription
value*

The value you want to test if text.

See
Returns:

Returns value if it is a string; otherwise an empty string.

Type: 
string
Examples
rosettajs.Text.t("HI"); // Returns "HI"
rosettajs.Text.t(5); // Return ""

(inner) text(value, format) → {TextOrTextList}

Converts any value to a text string.

Parameters:
NameTypeDescription
value*

Any value you want to convert to text.

formatTextOrTextList

format strings used to determine how the text is returned. For Open Formula, the format is required and only the first format string is used.

For Notes, the format is optional and can be up to four format strings. These determine how the text is returned. If value is already a string, format is ignored. This parameter is currently not implemented for Notes Formula.

See
Returns:

The value you specified, converted to text. If you used any format-strings, they are applied. and docs.oasis-open.org

Type: 
TextOrTextList
Examples
rosettajs.Text.text(123.45); // Returns "123.45" if using Notes Formula implementation
rosettajs.Text.text(0.285,"0.0%"); // Returns "28.5" if using Open Formula implementation

(inner) textAlignCenter()

Centers the current text.

Throws:

no plans to implement

Type
Error

(inner) textAlignFull()

Aligns text along the left margin.

Throws:

no plans to implement

Type
Error

(inner) textAlignLeft()

Aligns text along the left margin.

Throws:

no plans to implement

Type
Error

(inner) textAlignNone()

Reverses the previously specified alignment settings.

Throws:

no plans to implement

Type
Error

(inner) textAlignRight()

Aligns text along the right margin.

Throws:

no plans to implement

Type
Error

(inner) textBold()

Makes the selected and subsequently entered text bold. This command is a toggle; selecting it again removes the bold.

Throws:

no plans to implement

Type
Error

(inner) textBullet()

Applies the bullet attribute to selected and subsequently entered text.

Throws:

no plans to implement

Type
Error

(inner) textCycleSpacing()

Resets the interline spacing below the selected text to single, one and a half, or double.

Throws:

no plans to implement

Type
Error

(inner) textEnlargeFont()

Increases selected and subsequently entered text to the next larger point size.

Throws:

no plans to implement

Type
Error

(inner) textFont()

Displays the Properties box for the current text, where the user can select the typeface, size, color, and style attributes.

Throws:

no plans to implement

Type
Error

(inner) textItalic()

Italicizes the selected and subsequently entered text. This command is a toggle; selecting it a second time removes the italics.

Throws:

no plans to implement

Type
Error

(inner) textJoin(delimiter, ignore_empty, …args) → {string}

Combines the text from multiple ranges and/or strings.

Parameters:
NameTypeAttributesDescription
delimiter*

A text string, either empty, or one or more characters enclosed by double quotes, or a reference to a valid text string. If a number is supplied, it will be treated as text.

ignore_emptyboolean

If TRUE, ignores empty values.

argsArray.<string><repeatable>

Text item to be joined. A text string, or array of strings, such as a range of values.

See
Returns:

The string containing the joined text.

Type: 
string
Example
rosettajs.Text.textJoin(" ",TRUE, "The", "sun", "will", "come", "up", "tomorrow."); // Returns "The sun will come up tomorrow."

(inner) textNormal()

Removes all style attributes from selected and subsequently entered text.

Throws:

no plans to implement

Type
Error

(inner) textNumbers()

Applies the numbers attribute to selected and subsequently entered text.

Throws:

no plans to implement

Type
Error

(inner) textOutdent()

Outdents selected and subsequently entered text by narrowing its left margin.

Throws:

no plans to implement

Type
Error

(inner) textParagraph()

Displays the Paragraph Alignment panel of the Text Properties box.

Throws:

no plans to implement

Type
Error

(inner) textParagraphStyles()

Displays the Paragraph Styles panel of the Text Properties box.

Throws:

no plans to implement

Type
Error

(inner) textPermanentPen()

Toggles the permanent pen.

Throws:

no plans to implement

Type
Error

(inner) textReduceFont()

Decreases the selected text to the next smaller point size.

Throws:

no plans to implement

Type
Error

(inner) textSetFontColor()

Displays selected or subsequently entered text using the specified color.

Throws:

no plans to implement

Type
Error

(inner) textSetFontFace()

Displays selected or subsequently entered text using the specified typeface.

Throws:

no plans to implement

Type
Error

(inner) textSetFontSize()

Displays text using the specified point size.

Throws:

no plans to implement

Type
Error

(inner) textSpacingDouble()

Sets Interline spacing below the selected text to double.

Throws:

no plans to implement

Type
Error

(inner) textSpacingOneAndAHalf()

Sets interline spacing below the selected text to one and a half.

Throws:

no plans to implement

Type
Error

(inner) textSpacingSingle()

Sets interline spacing below the selected text to single.

Throws:

no plans to implement

Type
Error

(inner) textToNumber(text) → {NumberOrNumberList}

Converts a text string to a number, where possible.

Parameters:
NameTypeDescription
textTextOrTextList

The string you want to convert to a number. If the string contains both numbers and letters, it must begin with a number to be converted properly. For example, the string "12ABC" converts to 12, but "ABC12" produces an error.

See
Returns:

The string, converted to a number.

Type: 
NumberOrNumberList
Examples
rosettajs.Text.textToNumber('2500'); // returns 2500
rosettajs.Text.textToNumber('2500-xyz', '250.5abc', '333'); // returns [2500, 250.5, 333]

(inner) textUnderline()

Underlines selected and subsequently entered text. This command is a toggle; selecting it a second time removes the underlining.

Throws:

no plans to implement

Type
Error

(inner) toNumber(value)

Converts a value to a number.

Parameters:
NameTypeDescription
valuestring | number

Text, number, or list thereof. A value that cannot be converted returns the error, "The value cannot be converted to a Number."

See
Returns:

Number or number list. The value converted to a number.

Examples
rosettajs.Text.toNumber('2500'); // returns 2500
"rosettajs.Text.toNumber('2500', '250.5', '333'); // returns [2500, 250.5, 333]

(inner) toTime(time_text) → {DateOrDateList}

Converts a value with a data type of text or time to a date-time value.

Parameters:
NameTypeDescription
time_textDateOrDateList

The value to convert. A value that cannot be converted returns the error, "The value cannot be converted to a Number."

See
Returns:

The value converted to a date object.

Type: 
DateOrDateList
Examples
// Returns Date values [02/29/2008, 03/01/2008]
rosettajs.Text.toTime(["2/29/08", "3/1/08"]);
// Return Date with value returns 08/31/2021
rosettajs.Text.adjust(rosettajs.Text.toTime("08/29/21"),0,0,2,0,0,0);

(inner) trim(text) → {TextOrTextList}

Removes leading, trailing, and redundant spaces from a text string, or from each element of a text list.

Parameters:
NameTypeDescription
textTextOrTextList

The text to trim.

See
Returns:

The string, with extra spaces removed. and docs.oasis-open.org

Type: 
TextOrTextList
Examples
rosettajs.trim(' more  spaces '); // returns 'more spaces'
rosettajs.trim(' more  spaces ','  less spaces  '); // returns ['more spaces', 'less spaces']

(inner) unichar(number) → {string}

Returns the character specified by the code number.

Parameters:
NameTypeDescription
numbernumber

A number between 1 and 255 specifying which character you want. The character is from the character set used by your computer. Note: Excel for the web supports only CHAR(9), CHAR(10), CHAR(13), and CHAR(32) and above.

See
Returns:

The character specified by the code number.

Type: 
string
Example
rosetta.Text.unichar(65); // Returns "A"

(inner) unicode(text) → {number}

Returns a numeric code for the first character in a text string.

Parameters:
NameTypeDescription
textstring

The text for which you want the code of the first character.

See
Returns:

The character code for the first character in text.

Type: 
number
Example
rosetta.Text.unicode("A"); // Return 65

(inner) upper(text) → {string}

Converts text to uppercase.

Parameters:
NameTypeDescription
textstring

The text you want converted to uppercase. Text can be a reference or text string.

See
Returns:

The text converted to uppercase.

Type: 
string
Example
rosetta.Text.upper("Habc7"); // Returns "HABC7"

(inner) upperCase(text) → {TextOrTextList}

Converts the lowercase letters in the specified string to uppercase.

Parameters:
NameTypeDescription
textTextOrTextList

The string you want to convert to uppercase.

See
Returns:

The string, converted to uppercase letters.

Type: 
TextOrTextList
Examples
rosettajs.Text.upperCase('to upper case please'); // returns 'TO UPPER CASE PLEASE'
rosettajs.Text.upperCase('ABcd', 'efGH'); // returns ['ABCD', 'EFGH']

(inner) value(text)

Converts a text argument to a number.

Parameters:
NameTypeDescription
textstring

The text enclosed in quotation marks or a reference to a value containing the text you want to convert.

See
Returns:

The number represented by the text.

Examples
rosetta.Text.value("6"); // Returns 6
rosetta.Text.value("1E5"); // Returns 100000. Works with exponential notation.
rosetta.Text.value("7.25"); // Returns 7.25. Works with fractions.
rosetta.Text.value("50%"); // Returns 0.5. Works with percentages.

(inner) wide(text) → {TextOrTextList}

Converts half-pitch alphanumeric characters (single-byte characters -- SBCS) in the specified string to full-pitch alphanumeric characters (double-byte characters -- DBCS). This function works in Japanese, Korean, Simplified Chinese, and traditional Chinese environments. In the Japanese environment, this function can convert half-pitch Katakana as well.

Parameters:
NameTypeDescription
textTextOrTextList

The string you want to convert to double-byte characters.

See
Returns:

The string converted to double-byte characters.

Type: 
TextOrTextList
Examples
rosettajs.Text.wide("0123456789ABCDEFGHI"); // returns "0123456789ABCDEFGHI"
rosettajs.Text.wide(["0123456789ABCDEFGHI", "アイウABCエオカᄀᄁᆪ"]); // returns ["0123456789ABCDEFGHI", "アイウABCエオカㄱㄲㄳ"]

(inner) word(text, separator, number) → {TextOrTextList}

Returns the specified word from a text string. A "word" is defined as the part of a string that is delimited by the defined separator character. For example, if you specify a space (" ") as the separator, then a word is any series of characters preceded by and followed by a space (or the beginning or end of the string).

Parameters:
NameTypeDescription
textTextOrTextList

The string you want to scan.

separatorstring

The character that you want used to delimit a word in the string.

numbernumber

A position indicating which word you want returned from string. A positive number refers to the position of the word starting from the beginning where 1 is the first word. A negative number refers to the position of the word starting from the end where -1 is the last word.

See
Returns:

The word that holds the position specified by the number in the string; for example, if number is 3, returns the third word in the string. If a text list is used, returns (in list format) a word from each list that holds the specified position. Returns an empty string if number is out of range, except that 0 is equivalent to 1.

Type: 
TextOrTextList
Examples
rosettajs.Text.word("Larson, Collins, and Jensen", " ", 2); // Returns "Collins,"
rosettajs.Text.word("Larson,James,M.", ",", 3); // Returns "M."