ftnk.jp -> ~fumi -> ChangeLog -> 2003-09 -> 2003-09-29

前の日 / 次の日 / 最新 / 2003-09

2003-09 / 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

2003-09-29 Mon

[別の年の同じ日: 2002 2004 2005 2006 2007 2008 2009 2010

2つの文字列の先頭から等しい文字列を抜き出す [Ruby] はてぶ

Linuxビボ〜ろく
- 09-26 http://ponx.s5.xrea.com/bibo/20030926.html#p03
- 09-28 http://ponx.s5.xrea.com/bibo/20030928.html#p01
- 09-29 http://ponx.s5.xrea.com/bibo/20030929.html#p01
より.

def match_first(a,b)
  i = 0
  while a[i] and b[i] and a[i] == b[i]
    i+=1
  end
  a[0, i]
end

def match_first(a,b)
  a.size.times{|i|
    return(a[0,i]) if a[i] != b[i]
  } and a
end