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,
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
> 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
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
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