String Manipulation
- format formatString [value ...]
- Similar to the C function sprintf. The return value
is the
formatString
with the%
' sequences replaced with the values. - regexp [-indices] [-nocase] [--] expr string [matchVar] [subVar ...]
- Returns 1 if the regular expression expr matches the
string, 0 if it doesn't.
matchVar
is filled with the substring that matches the entire expression; thesubVar
variables, instead, receive the strings that match the subexpression (defined with the parentheses). - regsub [-all] [-nocase] [--] expr string subSpec resultStr
- As for regexp, a pattern matching on the string is
performed using expr. The matching substrings are
then replaced with the
subSpec
string and stored intoresultStr
. - scan string format varName [varName ...]
- Similar to the C function sscanf. Parses the fields
of the string according to the format string. Each
%
sequence is stored in the correspondingvarName
. Returns the number of fields successfully parsed. - string compare string1 string2
- As for strcmp, returns
- -1 if $string1 < $string2
- 0 if $string1 == $string2
- +1 if $string1 > $string2