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 String.trim_prefix/2, in order to be consistent with String.replace_prefix/3 where the same input as above should behave like this: iex> String.trim_prefix("--__--abc", [" ", "-", "_"]) "__--abc" Which also makes me think that String.replace_prefix should also behave like String.replace/3 where the second argument (match) is a pattern, not a string (ie. a string, list of strings, or a compiled search pattern). By introducing this last consistency change, the implementation of the consistency changes for the other functions mentioned above is straight-forward. So in short this consistency proposals suggests some functions to support t:String.pattern/0 which could be a string, a list of strings, or a compiled search pattern. 1. `String.replace_{leading, prefix, suffix, trailing}/3` to support in its second argument (match) t:String.pattern/0. Current String.replace/4 supports t:String.pattern/0 | t:Regex.t/0, but for the sake of simplifying this proposal I would leave out Regexes out of the equation for now. 2. Introduce String.trim_{prefix, suffix}/2 which will support t:String.pattern/0 as a its second arguments. These functions should mimic String.replace_{prefix, suffix}/2 3. Add support for t:String.pattern/0 for String.{trim, trim_leading, trim_trailing}/2 to support t:String.pattern/0 as its second argument. These functions should mimic String.{replace, replace_leading, replace_trailing}/3 Please let me know what you think. -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/621f703a.1c69fb81.2b06.fa97SMTPIN_ADDED_MISSING%40gmr-mx.google.com.