Hello everyone,

Currently the second argument of funtions String.{trim, trim_leading,
trim_trailing}/2  can only be a string.
I would like Elixir to support a list of strings to be trimmed, such as:

    String.trim_leading(tag_name, ["OTP_", "OTP-"])

There is a precedent of other functions taking list of strings as in
the case of `String.starts_with?/2`, `String.end_with?/2` and
`String.contains?/2`.

Currently it can be achieved with `String.replace_leading/3` and
`String.replace_trailing/3` but:
  1. by using "" as the replacement it is not as clear as what trim
 conveys.
  2. There is no direct replacement for `String.trim` and two
 function calls are needed:
    string |> String.replace_leading([" ", "-", "_"], "") |>
String.replace_trailing([" ", "-", "_"], "") 

where with this would suffice.
    String.trim(string, [" ", "-", "_"])

Please let me know what you think about it.

-- 
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/61f03282.1c69fb81.c069d.3393SMTPIN_ADDED_MISSING%40gmr-mx.google.com.

Reply via email to