# File lib/facet/string/first&last.rb, line 13 def first(n=1, separator=$/) separator = /\n+/ if separator == '' separator = /\s+/ unless separator separator = Regexp.new( Regexp.escape( separator ) ) if String === separator i,s = 0,0 n.times { i = self.index(separator,s); s = $~.end(0) } return self[0...i] end