Skip to content

Conversation

@vanstee
Copy link
Contributor

@vanstee vanstee commented Aug 23, 2013

To stay consistent with both String.split/2 and :binary.split we
need to keep around empty strings that are accumulated while splitting.
In the future we could support the :trim option to consistently remove
these in call calls to String.split.

Fixes #1636

To stay consistent with both `String.split/2` and `:binary.split` we
need to keep around empty strings that are accumulated while splitting.
In the future we could support the `:trim` option to consistently remove
these in call calls to `String.split`.

Fixes elixir-lang#1636
josevalim pushed a commit that referenced this pull request Aug 24, 2013
Keep empty strings when splitting
@josevalim josevalim merged commit fb30101 into elixir-lang:master Aug 24, 2013
@josevalim
Copy link
Member

Thanks @vanstee. Could you also please send a pull request that adds trim: true but that would trim both the left and right side? Thanks! :)

@vanstee vanstee deleted the string-split-repeats branch August 24, 2013 18:01
@vanstee
Copy link
Contributor Author

vanstee commented Aug 24, 2013

Sure. Should it also remove empty strings from the middle? Should we make trim: true the default like global?

@josevalim
Copy link
Member

@vanstee I think we could trim by default, that's a good idea. I will hold the release on this, so we don't break the behaviour now just to break it again. @ericmj, what do you think?

@ericmj
Copy link
Member

ericmj commented Aug 24, 2013

I'm hesitant to trimming by default. Are any other languages trimming by default? If we trim I think we should trim the middle as well.

@meh
Copy link
Contributor

meh commented Aug 24, 2013

@ericmj Ruby does.

>> "lol   wut ".split(' ')
=> ["lol", "wut"]

@ericmj
Copy link
Member

ericmj commented Aug 24, 2013

Looks like Python trims by default as well. Haskell and .NET does not. Consistent among all default trimmers is that they trim the middle as well.

@josevalim
Copy link
Member

Ok, let's trim by default and trim in the middle too!

@vanstee
Copy link
Contributor Author

vanstee commented Aug 25, 2013

Sounds good!

vanstee added a commit to vanstee/elixir that referenced this pull request Aug 26, 2013
…-repeats"

This reverts commit fb30101, reversing
changes made to c348eb7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

String.split does not fully remove repeated patterns

4 participants