|
setup diary |
python | ruby 1.8 and 1.9 |
s="2010's" | s="2010's" or %Q(2010's) |
s='"2010"' | s=%Q'"2010"' |
s=r'c:\user' | s='c:\user' or %q(c:\user) |
s=u'\u9300' | s="\u9300"(1.9) |
s=u'\U00028b46' | s="\u{028b46}"(1.9) |
s="%dK,%fPa"%(273,1024) | s="%dK,%fPa"%[273,1024] |
s="""first | s="first |
second"""" | second" |
s[2] | s[2,1] or s[2].chr(1.8) and s[2](1.9) |
s[1:3] | s[1...3] or slice(1...3) |
len(s) | s.size or s.length |
int("1") | "1".to_i |
float("3.14") | "3.14".to_f |
s.count('0') | s.count('0') |
s.capitalize() | s.capitalize |
s.swapcase() | s.swapcase |
s.upper() | s.upcase |
s.lower() | s.downcase |
s.center(10) | s.center(10) |
s.ljust(10) | s.ljust(10) |
s.rjust(10) | s.rjust(10) |
s.strip() | s.strip |
s.lstrip() | s.lstrip |
s.rstrip() | s.rstrip |
s.find('1') | s.index('1') |
s.rfind('1') | s.rindex('1') |
s.split(',') | s.split(/,/) |
",".join(["a","b"]) | ["a","b"].join(",") |
s.replace('a','A') | s.gsub!(/a/){'A'} |
s.replace('a','A',1) | s.sub!(/a/){'A'} |