ruby picture

RCR 136: String#chomp(/regexp/)

Submitted by anonymous (Sat May 03 11:05:17 UTC 2003)

Abstract

This is a legacy RCR from Ruby Garden, submitted by anonymous. Matz has declared these RCRs obsolete, and asked that their authors resubmit them in the new format.

I think it would be a nice feature to be able to do something like str.chomp(/r?n/) to cut off both dos and unix style newlines. (This can already be done like str.subs(/r?n$/), but str.chomp(/re/) would look more like a chomp and be slightly simpler.)

Problem

(RCR imported from old format)

Proposal

Analysis

(RCR imported from old format)

Implementation

(RCR imported from old format)
ruby picture
Comments Current voting

Check out ri 1.8 (root, 2003-05-03 07:38:17)

You can already use chomp to strip DOS or Unix line endings (that is, it'll remove CR/LF or just LF). It doesn't take regexps though.


Strongly opposed 0
Opposed 0
Neutral 0
In favor 0
Strongly advocate 0
ruby picture
If you have registered at RCRchive, you may now sign in below. If you have not registered, you may sign up for a username and password. Registering enables you to submit new RCRs, and vote and leave comments on existing RCRs.
Your username:
Your password:

ruby picture

Powered by .