Skip to content

Add trim_prefix and trim_suffix in string.gleam#905

Open
gungun974 wants to merge 2 commits intogleam-lang:mainfrom
gungun974:main
Open

Add trim_prefix and trim_suffix in string.gleam#905
gungun974 wants to merge 2 commits intogleam-lang:mainfrom
gungun974:main

Conversation

@gungun974
Copy link

See #743

This PR is still a draft and for now I only implement trim_prefix and trim_suffix that just trim the string without returning any error. (if there is no pattern, it's the same string as input)

(That's the same behavior and API from the golang strings package, https://pkg.go.dev/strings#TrimSuffix)

@gungun974
Copy link
Author

I added strip_prefix and strip_suffix as there were the original goal of #743 which I misunderstood.

They do the similar thing as trim_prefix and strip_suffix however if the string don't have the prefix or suffix, a Error(Nil) is return which make possible for doing stuff with a case (for example adding a new prefix if the stripping was sucessfull otherwise return the original string)

@gungun974 gungun974 marked this pull request as ready for review February 11, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant