Table of Contents
There are 6 string subcommands that do pattern and string matching. These are relatively fast operations, certainly faster than regular expressions, albeit less powerful.
string compare string1 string2Compares string1 to string2 and returns:
-1 ..... If
string1 is less than
string2
0 ........ If
string1 is equal to
string2
1 ........ If
string1 is greater than
string2
These comparisons are done alphabetically, not numerically - in other words "a" is less than "b", and "10" is less than "2".
string first string1 string2Returns the index of the character in
string1 that starts the first match to
string2, or -1 if there is no match.
string last string1 string2Returns the index of the character in
string1 that starts the last match to
string2, or -1 if there is no match.
string wordend string indexReturns the index of the character just after the last one in the word which contains the
index'th
character of
string. A word is any
contiguous set of letters, numbers or underscore characters, or a
single other character.
string wordstart string indexReturns the index of the character just before the first one in the word which contains the
index'th
character of
string. A word is any
contiguous set of letters, numbers or underscore characters, or a
single other character.
string match pattern stringReturns 1 if the
pattern matches
string. The
pattern is a