Skip to content

Add trim_prefix and trim_suffix in string.gleam#905

Merged
lpil merged 2 commits intogleam-lang:mainfrom
gungun974:main
Apr 1, 2026
Merged

Add trim_prefix and trim_suffix in string.gleam#905
lpil merged 2 commits intogleam-lang:mainfrom
gungun974:main

Conversation

@gungun974
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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
Copy link
Copy Markdown
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

@lpil lpil merged commit 93636ce into gleam-lang:main Apr 1, 2026
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.

2 participants