Skip to content
New issue

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

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

Already on GitHub? # to your account

Add regex.escape #677

Open
apainintheneck opened this issue Aug 14, 2024 · 2 comments
Open

Add regex.escape #677

apainintheneck opened this issue Aug 14, 2024 · 2 comments

Comments

@apainintheneck
Copy link
Contributor

This would take a string and return a string with all regex-specific characters escaped so that it would match the literal string if compiled to a regex. It would be useful when you want to exactly match part of a string while partially matching other parts a string. I'm not sure how difficult this would be to add though because of the differences between JS and Erlang regex syntax.

fn escape(string: String) -> String

Related:

@apainintheneck
Copy link
Contributor Author

Looking into things a bit further it seems like the Regex syntax for each platform might be similar enough in terms of matacharacter usage that this won't be a big lift. Even though the JS Regex Syntax seems to have more features if we escape common metacharacters (see the Erlang re docs) things might just work.

@apainintheneck
Copy link
Contributor Author

apainintheneck commented Aug 18, 2024

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant