23rd Sat
s21gの意味(?)
ruby>>
def shotening(str)
return str[0..0] + str[1..-2].gsub!(/\s/,"").size.to_s + str[-1..-1]
end
str = "something new and exciting"
shotening(str) #=> "s21g"
<<ruby
ってことなんですかね?
posted by
y_tsuda on Sat 23 Aug 2008 at 23:03 with 2 comments
"something new and exciting".sub(/^(.)(.+)(.)$/) {"#{$1}#{$2.scan(/\S/).size}#{$3}"}
<<ruby
というのはどうでしょう。
ご明察! 短いドメイン名がとりたかったんですよねー。