$right

From Scriptwiki
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

See Also