$right

From Scriptwiki
Revision as of 18:00, 16 December 2005 by Albie (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Returns the N right characters of text.

$right(text,N)

$right(girlfriend.jpg, 3) returns jpg, the last three characters from the end.

By giving N a negative value you get all except N characters from the end. $right(girlfriend.jpg, -4) returns friend.jpg, leaving out the first four characters.

Example

$right and other Identifiers

What about if you don't know what extention a filetype is, is it going to be jpg or png, friend.jpg or friend.png. We can use

$right(friend,3)

to get the result.

$right and aliases

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

Prints:

a
ga
nga
unga
bunga
abunga
wabunga
awabunga
cawabunga

Also See