Lahey/Fujitsu Fortran

Character Substrings

A character string is a sequence of characters in a CHARACTER data object. The characters in the string are numbered from left to right starting with one. A contiguous part of a character string, called a substring, can be accessed using the following syntax:

string ( [lower-bound] : [upper-bound] )

string is a string name or a CHARACTER literal.

lower-bound is the lower bound of a substring of string.

upper-bound is the upper bound of a substring of string.

If absent, lower-bound and upper-bound are given the values one and the length of the string, respectively. A substring has a length of zero if lower-bound is greater than upper-bound. lower-bound must not be less than one.

For example, if abc_string is the name of the string "abcdefg",

abc_string(2:4) is "bcd"
abc_string(2:) is "bcdefg"
abc_string(:5) is "abcde"
abc_string(:) is "abcdefg"
abc_string(3:3) is "c"
"abcdef"(2:4) is "bcd"
"abcdef"(3:2) is a zero-length string