Forum: Ruby instead of re.sub

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5050e33d097eb62c576e4f150efed79b?d=identicon&s=25 cihan (Guest)
on 2007-06-16 13:09
hi I want to remove all \n parts of a .txt file but I can't find the
command.

If I use .sub the code makes the only first replacement but I need it to
check all of the file.

In python language they use re but in ruby what should I do? please give
me a way.
C40020a47c6b625af6422b5b1302abaf?d=identicon&s=25 Stefano Crocco (crocco)
on 2007-06-16 13:24
(Received via mailing list)
Alle sabato 16 giugno 2007, cihan ha scritto:
> hi I want to remove all \n parts of a .txt file but I can't find the
> command.
>
> If I use .sub the code makes the only first replacement but I need it to
> check all of the file.
>
> In python language they use re but in ruby what should I do? please give
> me a way.

Use gsub instead of sub.

Stefano
This topic is locked and can not be replied to.