Sha256: 66852d3a29f64c1256bf7c8efaa9d80d5dc428129956b155a8a3b2981cfb1cd2

Contents?: true

Size: 394 Bytes

Versions: 7

Compression:

Stored size: 394 Bytes

Contents

class String

  # Breaks a string up into an array based on a regular expression.
  # Similar to scan, but includes the matches.
  #
  #   s = "<p>This<b>is</b>a test.</p>"
  #   s.divide( /\<.*?\>/ )
  #
  # _produces_
  #
  #   ["<p>This", "<b>is", "</b>a test.", "</p>"]
  #
  #   CREDIT: Trans

  def divide( re )
    re2 = /#{re}.*?(?=#{re}|\Z)/
    scan(re2) #{re}(?=#{re})/)
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/string/divide.rb
facets-2.4.1 lib/facets/string/divide.rb
facets-2.4.3 lib/core/facets/string/divide.rb
facets-2.4.2 lib/core/facets/string/divide.rb
facets-2.4.4 lib/core/facets/string/divide.rb
facets-2.4.5 lib/core/facets/string/divide.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/string/divide.rb