STScI Logo

strings language


NAME · USAGE · DESCRIPTION · EXAMPLES · SEE_ALSO

NAME

strings -- string manipulation functions available in the CL

USAGE

str     (x)
substr  (str, start, end)
stridx  (test, str)
strldx  (test, str)
strlen  (str)
strlwr  (str)
strupr  (str)
strstr  (str1, str2)
strlstr (str1, str2)

DESCRIPTION

The following functions are available for the manipulation of strings within the CL. All string positions are returned as 1-indexed values.

str (x)
Converts its argument into a string. The argument may be boolean, integer or real.
substr (str, first, last)
Extracts a substring from string str . The last value may be larger than first , in which case the returned string is reversed. The first character in the string is at index 1.
stridx (test, str)
Finds the position of the first occurence of any character found in test in the string str , returning 0 if the match fails.
strldx (test, str)
Finds the position of the last occurence of any character found in test in the string str , returning 0 if the match fails.
strlen (str)
Returns the current length of a string. Note that the maximum length may be obtained as the value of the expression `param.p_length'.
strlwr (str)
Converts str to all lower-case characters, returns a string value.
strupr (str)
Converts str to all upper-case characters, returns a string value.
strstr (str1, str1)
Finds the position of the first occurence of str1 in str2 (an exact match is required), or 0 if the match fails.
strlstr (str1, str1)
Finds the position of the last occurence of str1 in str2 (an exact match is required), or 0 if the match fails.

EXAMPLES

1. Simple function calls.

	s = str(y)			     # convert y to a string.
	s = substr  ("abcdefg", 2, 4)	     # s = "bcd"
	s = substr  ("abcdefg", 4, 2)	     # s = "dcb"
	i = stridx  ("abc", " eeboq")	     # i = 4
	i = strldx  ("/", "/path/image.imh") # i = 6
	i = strlen  ("abc")		     # i = 3
	s = strlwr  ("ABC")		     # s = "abc"
	s = strupr  ("abc")		     # s = "ABC"
	i = strstr  ("imh","imhead.imh")     # i = 1
	i = strlstr ("imh","imhead.imh")     # i = 8

SEE ALSO

scan, radix


Search Form · STSDAS