Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to replace a suffix? #48

Open
bapcyk opened this issue Mar 30, 2023 · 3 comments
Open

How to replace a suffix? #48

bapcyk opened this issue Mar 30, 2023 · 3 comments

Comments

@bapcyk
Copy link

bapcyk commented Mar 30, 2023

Hello dear author, this package is brilliant.

It's not a bug, just a question: is it possible (and how?) to replace a suffix (or prefix) in a string? Because the replace replaces a fragment everywhere, for instance in the middle of a string. For example, I want to replace ".exe" - it's suffix/executable extension. All my attempts replace it in "aaa.exe.tail" too. I tried to use empty but it does not help.

replace (some anySym <* ".exe") "aaa.exe"  -- the simplest example
@bapcyk
Copy link
Author

bapcyk commented Apr 4, 2023

Maybe there is a way to implement missing $ and ^ typical for many regex syntax?

@treeowl
Copy link

treeowl commented Apr 4, 2023

For prefixes, you should look at findFirstPrefix, findLongestPrefix, and findShortestPrefix. For suffixes, I think you need to use match with an appropriate argument.

@bapcyk
Copy link
Author

bapcyk commented Apr 5, 2023

For prefixes, you should look at findFirstPrefix, findLongestPrefix, and findShortestPrefix. For suffixes, I think you need to use match with an appropriate argument.

I mean for replace, not for matching/searching. Otherwise the replace function replace it many times in any position where it finds the pattern

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

No branches or pull requests

2 participants