String Operations

eSignal EFS

String Operations

 

The String Object represents a series of characters in a string.

 

String Constructors:

 

var a = "This is a string";

var b = new String("This is another string");

 

String Properties:

 

length length of this string.

var s = "Testing 123";

var n = s.length;

/* n = 11 */

 

String Methods:

 

charAt(nIndex) Returns the character nIndex.

nIndex is a value between the first character of a string (index 0), and the last character of a string (length - 1).

var s = "MACD Slope";

var c = s.charAt(5);

/* The variable c will contain 'S' */

 

indexOf(sValue, [nStartIndex] ) Returns the index within this string of the first occurrence of sValue starting at the optional nStartIndex.

var s = "MACD Slope";

var n = s.IndexOf("Slope");

/* n = 5 */

 

lastIndexOf(sValue, [nStartIndex] ) Returns the index within this string of the last occurrence of sValue searching backward starting at the optional nStartIndex.

var s = "Abc123Abc123";

var n = s.IndexOf("abc");

/* n = 6 */

 

split(sSeparator, nLimit) Splits this string around matches of sSeparator

var s = "She sells sea shells by the sea shore."

Var ss = s.split(" ");

Returns an arrary of strings

ss[0] = "she"

ss[1] = "sells"

ss[…] = 

ss[n] = "shore.";

 

substr(nStartIndex, nLength) Returns a substring beginning at nStartIndex, extracting nLength characters.

var s = "abcdef";

var s2 = s.substr(2,3);

/* s2 = "cde" */

 

substring(nStartIndex, nEndIndex) Returns a substring spanning from nStartIndex to nEndIndex.

var s = "abcdef";

var s2 = s.substring(2, 4);

/* s2 = "cde" */

 

toLowerCase() Returns a lowercase representation of the string.

var s = "UpperCase";

var s2 = s.toLowerCase();

/* s2 = "uppercase"; */

 

toUpperCase() Returns a uppercase representation of the string.

var s = "UpperCase";

var s2 = s.toUpperCase();

/* s2 = "UPPERCASE"; */