# File lib/facet/string/first.rb, line 18
  def first(n=1, pattern='')
    pattern = '' if pattern == //
    case pattern
    when ''
      return slice(0,n)
    when "\n"
      pattern = /\n+|\Z/
    when nil
      pattern = /\s+|\Z/
    when String
      pattern = Regexp.new( Regexp.escape( separator ) ) #if String === separator
    end

    i,s,e = 0,0,0
    n.times {
      i = self.index( pattern, s )
      break unless i
      e = i
      s = $~.end(0)
    }
    slice(0...e)
  end