title: Why does Ruby String#split not treat consecutive trailing delimiters as separate entities?
body: <p>I'm reading from a government text file in which $ is used as the delimiter, but I don't think  delimiter character matters...</p>
  
  <p>So this is expected:</p>
  
  <pre><code>'a$b$c$d'.split('$')
  # =&gt; ["a", "b", "c", "d"]
  </code></pre>
  
  <p>In the datafiles I'm working with, the column headers row (the first line) are uniformly filled in, i.e. there is no empty header, as in:</p>
  
  <pre><code>'a$b$$d'
  # or: 
  'a$b$c$'
  </code></pre>
  
  <p>However, each row may have consecutive trailing delimiters such as:</p>
  
  <pre><code>"w$x$$\r\n"
  </code></pre>
  
  <p>Usually, I read each line and <strong>chomp</strong> it. But this causes String#split to treat the final two delimiters as one column:</p>
  
  <pre><code>"w$x$$\r\n".chomp.split('$')
  # =&gt; ["w", "x"] 
  </code></pre>
  
  <p>Not doing the chomp gets me the desired result, though I should chomp the last element:</p>
  
  <pre><code>"w$x$$\r\n".split('$')
  # =&gt; ["w", "x", "", "\r\n"]
  </code></pre>
  
  <p>So either I have to:</p>
  
  <ul>
  <li>chomp the line <strong>if</strong> the final non-newline characters are NOT consecutive delimiters</li>
  <li>preserve the newline, do the split, and then chomp the final element IF the final characters are consecutive delimiter</li>
  </ul>
  
  <p>This seems really awkward...am I missing something here?</p>