X
Xah Lee
# strings can be joined by +.
print "this" + " that"
# string can be multiplied
print "this" *5
# substring extraction is done by appending a bracket
# with begin and ending index
a="this and that"
print a[3:6]
# index can be negative,
# and sometimes out of bound will just mean length of the string
print a[3:-2]
# length of the string is len()
print len(a)
-------------------------
# in perl, string join is done with a dot.
$astr= "this" . "that";
# string repeatition is done with an x
print $astr x 5;
# string extraction is done with substr()
# for more about sbstr(), see verbose
# perldoc -tf substr
# length of string is length();
print length $astr;
Xah
(e-mail address removed)
http://xahlee.org/PageTwo_dir/more.html
print "this" + " that"
# string can be multiplied
print "this" *5
# substring extraction is done by appending a bracket
# with begin and ending index
a="this and that"
print a[3:6]
# index can be negative,
# and sometimes out of bound will just mean length of the string
print a[3:-2]
# length of the string is len()
print len(a)
-------------------------
# in perl, string join is done with a dot.
$astr= "this" . "that";
# string repeatition is done with an x
print $astr x 5;
# string extraction is done with substr()
# for more about sbstr(), see verbose
# perldoc -tf substr
# length of string is length();
print length $astr;
Xah
(e-mail address removed)
http://xahlee.org/PageTwo_dir/more.html