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