Difference between revisions of "$left"

From Scriptwiki
Jump to: navigation, search
m
m
 
(One intermediate revision by one other user not shown)
Line 36: Line 36:
 
  cawabunga
 
  cawabunga
  
 +
== Also See ==
 +
*[[$right]]
 +
*[[$mid]]
 
[[Category:Text_and_Number_Identifiers]]
 
[[Category:Text_and_Number_Identifiers]]

Latest revision as of 16:50, 16 December 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

Also See