Sha256: cef9bf085e4ce65e12315ce3de852aed8c4d01b48b1b7da70c85e80655c16fb0

Contents?: true

Size: 239 Bytes

Versions: 3

Compression:

Stored size: 239 Bytes

Contents

require 'pry'
class String
  #Extending string class to return the count of substr inside a string
  def substr_count(needle)
    needle = "\\#{needle}" if(needle == '|') # To escape inside regex
    self.scan(/(#{needle})/).size
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csv-import-analyzer-0.0.3 lib/csv-import-analyzer/helpers/string_class_extensions.rb
csv-import-analyzer-0.0.2 lib/csv-import-analyzer/helpers/string_class_extensions.rb
csv-import-analyzer-0.0.1 lib/csv-import-analyzer/helpers/string_class_extensions.rb