Sha256: f5136eaaa458ec8fa1a6b76e6f905f2ae5b2fb986fe6d0dfe5befe0e1b667706
Contents?: true
Size: 573 Bytes
Versions: 11
Compression:
Stored size: 573 Bytes
Contents
unless String.method_defined? :remove_prefix class String # Removes a prefix in a string. # # @return [String] a new string without the prefix. # # @example # 'Ladies Night'.remove_prefix('Ladies ') #=> 'Night' def remove_prefix(pattern) dup.remove_prefix!(pattern) end # Removes a prefix in a string. # # @return [String] the string without the prefix. # # @example # 'Ladies Night'.remove_prefix!('Ladies ') #=> 'Night' def remove_prefix!(pattern) gsub!(/\A#{pattern}/, '') end end end
Version data entries
11 entries across 11 versions & 3 rubygems