I suspect that these are common enough needs that it would be nice to have them in the standard library.
Of course I know that I can already accomplish it with std.endsWith/std.startsWith, std.length and slice syntax:
local trimSuffix(str, suffix) =
if std.endsWith(str, suffix) then
str[0:std.length(str) - std.length(suffix)]
else
str;
I could also use std.strReplace if I was 100% sure the prefix/suffix would never exist anywhere else in the string.
I'm not sure what the goal of the standard library is. Perhaps you just want to provide the minimum set of building blocks for people to make their own methods like above. If the goal is instead to provide a suite of commonly used functions, these would be a great addition to it.
I suspect that these are common enough needs that it would be nice to have them in the standard library.
Of course I know that I can already accomplish it with
std.endsWith/std.startsWith,std.lengthandslicesyntax:I could also use
std.strReplaceif I was 100% sure the prefix/suffix would never exist anywhere else in the string.I'm not sure what the goal of the standard library is. Perhaps you just want to provide the minimum set of building blocks for people to make their own methods like above. If the goal is instead to provide a suite of commonly used functions, these would be a great addition to it.