Difference between revisions of "$right"

From Scriptwiki
Jump to: navigation, search
 
m
 
Line 36: Line 36:
 
  cawabunga
 
  cawabunga
  
== Also See ==
+
== See Also ==
*[[$left]]
+
* [[$left]]
*[[$mid]]
+
* [[$mid]]
  
 
[[Category:Text_and_Number_Identifiers]]
 
[[Category:Text_and_Number_Identifiers]]

Latest revision as of 10:07, 2 July 2007

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