-
-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
These functions would return an Ok value with the prefix or suffix stripped, or an Error(Nil) value when the prefix or suffix does not exist in the string.
case string.strip_prefix("https://gleam.run", "https://") {
Ok(site) -> "found site " <> site
Error(Nil) -> "no site found"
}
// -> "found site gleam.run"
(I know this can be done with adding strings in pattern matching, but this would be useful in pipes and there is no way to handle strip_suffix with that approach)
You can already achieve this through combining string.starts_with
and string.drop_start
, but that's rather clunky and this feels much more gleam-y to me.
I find myself using them a decent amount when I write rust, and I noticed they're even used several times in the gleam compiler!
JosephTLyons, lajp and NNBnh
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed