String Functions

@compare, @comp, @strcmp

Compare two strings, giving -1 if string1 is less than string2, 0 if string1 is equal to string2, or 1 if string1 is greater than string 2. @comp and @strcmp are aliases for @compare.

@concat

Concatenate a list of strings together, and return the new string.

@set(newstring, @concat("prefix", "suffix"))

@substr

Get a substring of the given string.

@# Extract one character from the alphabet
@set(x, "abcdefghijklmnopqrstuvwxyz")\
@set(i, 9)\
@substr(x, i, 1)

This sample will return "j" from the x symbol.

@length

Give the length of the given string.

@if (@length(x) > 80) {
	x is too long
}

@empty

Return 1 if string is empty or 0 if string is not empty. If given a hash or array, @empty will report an error and return nothing.

@if (@empty(x)) {
	@set(x, "[empty]")\
}

@lc

Give the lowercase version of the given string.

@if (@compare(@lc(x), "foo")) {
	x is not foo
}

@uc

Give the uppercase version of the given string.

@if (@compare(@uc(x), "FOO")) {
	x is not FOO
}

@lpad

(1.10+)

Pad the left side of the specified string with spaces until the string is the specified width. If the string is already greater than or equal to the specified width, @lpad simply returns the original string.

@lpad(string, width)

@rpad

(1.10+)

Pad the right side of the specified string with spaces until the string is the specified width. If the string is already greater than or equal to the specified width, @rpad simply returns the original string.

@rpad(string, width)

@repeat

(1.20+)

Repeat the specified text or expression the specified number of times. Any repeat value of 0 or less will produce nothing.

@# Fill the next line with a solid line of dashes
@repeat("-", 80)