Instant methods: left()

The instant method left() returns the leftmost part from a string operand.

Declaration

string string.left( int32 aCount )

Parameters

aCount

Maximal number of characters to return.

Discussion

The left() method copies up to aCount leading characters from the string, in context of which it has been called and returns the copied characters as a new string without modifying the original string operand. If aCount <= 0 the method returns always an empty string "". For example:

var string s1 = "green blue red"; var string result = s1.left( 5 ); // result = "green" var string result = s1.left( 10 ); // result = "green blue" var string result = s1.left( 100 ); // result = "green blue red" var string result = s1.left( -10 ); // result = ""