Difference between revisions of "$left"

From Scriptwiki
Jump to: navigation, search
m
(added author)
Line 35: Line 35:
 
  cawabung
 
  cawabung
 
  cawabunga
 
  cawabunga
 +
 +
{{Author|Tovrleaf}}
  
 
[[Category:Text_and_Number_Identifiers]]
 
[[Category:Text_and_Number_Identifiers]]

Revision as of 18:03, 31 August 2005

Returns the N left characters of text.

$left(text,N)

$left(girlfriend.jpg, 10) returns girlfriend, the first ten characters from the beginning.

By giving N a negative value you get all except N characters. $left(girlfriend.jpg, -4) returns the same value.

Examples

$left and other identifiers

What about if you don't know users gender, is it going to be she or he, boyfriend.jpg or girlfriend.jpg We can use

$left(girlfriend, $pos(girlfriend.jpg, ., 1))

to get the same result.

$left and aliases

var %c = 1, %str = cawabunga
while (%c <= $len(%str)) {
  echo -a $left(%str, %c)
  inc %c
}

Prints:

c
ca
caw
cawa
cawab
cawabu
cawabun
cawabung
cawabunga
Contributed by Tovrleaf