Re: [elixir-core:10821] Proposal: Add support for list of strings in String.{trim, trim_leading, trim_trailing}

2022-03-02 Thread 'eksperimental' via elixir-lang-core
Well, all these questions came up when I started implementing a solution, and the further I looked the higher I climbed up the branches. I will limit the scope to string and list of strings as you suggest, later we can extend it if necessary. If i see the need to implement a trim_{prefix,

Re: [elixir-core:10820] Proposal: Add support for list of strings in String.{trim, trim_leading, trim_trailing}

2022-03-02 Thread José Valim
Sorry, I got so wrapped up on the proposal that I forgot about your example. :D We can make replace_leading/trailing/prefix/suffix accept t | [t] and that would solve your use case. We already accept only this subset on starts_with? / ends_with?, so I think it is a natural extension here. Then

Re: [elixir-core:10819] Proposal: Add support for list of strings in String.{trim, trim_leading, trim_trailing}

2022-03-02 Thread 'eksperimental' via elixir-lang-core
> So unless there is a strong > reason for adding this, rather than consistency, I would not go this > route. Personally I don't think it is an inconsistency because there is no equivalent of String.trim_leading/1 (or the equivalent makes no sense, or hardly has any use). The need for

Re: [elixir-core:10818] Proposal: Add support for list of strings in String.{trim, trim_leading, trim_trailing}

2022-03-02 Thread José Valim
Thanks for the proposal. I believe we don't support all patterns because it will be inefficient, especially the suffix/trailing functions. It is not necessarily trivial to implement it for regexes either (and regexes have their own mechanism to represent prefixes/suffixes). The reason we don't

Re: [elixir-core:10817] Proposal: Add support for list of strings in String.{trim, trim_leading, trim_trailing}

2022-03-02 Thread 'eksperimental' via elixir-lang-core
When starting to work in this implementation was wondering what should be the return value of String.trim_leading("--__--abc", [" ", "-", "_"]) and I realized that it should mimic String.replace_leading/3 Therefore it should returning "abc" Which leads me to think we should introduce