Is there a reason to not have String.chomp?

577 views
Skip to first unread message

meh.

unread,
Sep 8, 2013, 6:34:47 AM9/8/13
to elixir-l...@googlegroups.com
I'm writing an IRC server and I need to chomp the incoming line, strip
would also remove leading whitespace which I don't want to happen.

I'd use String.rstrip/2 but I'd need to chomp /\r?\n$/ and I'd rather
not use a full blown regex for something like this.

Any suggestions? Or want a pull for String.chomp?

Peter Minten

unread,
Sep 8, 2013, 6:49:44 AM9/8/13
to elixir-l...@googlegroups.com
Wouldn't String.rstrip/1 do what you need or do you want to avoid
stripping trailing spaces?

meh.

unread,
Sep 8, 2013, 7:10:16 AM9/8/13
to elixir-l...@googlegroups.com
On Sun, Sep 08, 2013 at 12:49:44PM +0200, Peter Minten wrote:
> Wouldn't String.rstrip/1 do what you need or do you want to avoid
> stripping trailing spaces?

I want to keep the trailing spaces.

Alexei Sholik

unread,
Sep 8, 2013, 7:15:48 AM9/8/13
to elixir-lang-core
We have rstrip/2. It could take a list of characters or even strings as the second argument. This would be somewhat analogous to how contains? works today.
--
Best regards
Alexei Sholik

meh.

unread,
Sep 9, 2013, 6:10:21 AM9/9/13
to elixir-l...@googlegroups.com
On Sun, Sep 08, 2013 at 02:15:48PM +0300, Alexei Sholik wrote:
> We have rstrip/2. It could take a list of characters or even strings as the
> second argument. This would be somewhat analogous to how contains? works
> today.

That would be perfect.

José Valim

unread,
Sep 9, 2013, 8:13:36 AM9/9/13
to elixir-l...@googlegroups.com
Sounds good!



José Valim
Skype: jv.ptec
Founder and Lead Developer
Reply all
Reply to author
Forward
0 new messages