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

add EReg.escape #5098

Merged
merged 1 commit into from
Apr 25, 2017
Merged

add EReg.escape #5098

merged 1 commit into from
Apr 25, 2017

Conversation

nadako
Copy link
Member

@nadako nadako commented Apr 11, 2016

I need this from time to time and I think it should be in the std lib. I tried to use platform-native (or recommended) regex escaping functions, but for others (cpp,neko,hl,lua) I used the implementation involving map. It works but it may not be the most efficient solution which can be improved in future.

I know we're in feature freeze, but this addition seems to be very minor and safe for 3.3.

@nadako
Copy link
Member Author

nadako commented Apr 12, 2016

If no comments follow, I'll merge this later today.

@Simn Simn added this to the 3.4 milestone Apr 12, 2016
@Simn
Copy link
Member

Simn commented Apr 12, 2016

Let's please wait with this, there's no reason to rush this into the RC and I'm not even sure what use-cases this has.

@nadako
Copy link
Member Author

nadako commented Apr 12, 2016

One use-case I had lately is with hxmustache. It uses regexp-based parsing and one can specify custom tags (e.g. (: instead of {{), so we need to escape given string to use it in a regex.

@fponticelli
Copy link
Contributor

There is a lot of value in that function to build runtime patterns. I
totally support its presence in std, in fact I have it already in thx.core.
You might refer it to double check the escaping logic:
https://github.com/fponticelli/thx.core/blob/master/src/thx/ERegs.hx

On Tue, Apr 12, 2016 at 5:26 AM, Dan Korostelev notifications@github.com
wrote:

One use-case I had lately is with hxmustache. It uses regexp-based parsing
and one can specify custom tags (e.g. (: instead of {{), so we need to
escape given string to use it in a regex.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#5098 (comment)

@Simn Simn modified the milestones: 3.4, 4.0 Jan 9, 2017
@Simn
Copy link
Member

Simn commented Mar 20, 2017

We can merge this, but you'll have to change the CHANGES.txt commit.

Also it would obviously be nice to have some tests...

@fullofcaffeine
Copy link

+1 for this, I recently needed this while converting some codebase from C# and had to come up with my own implementation. I didn't know thx had it at the time. As always @fponticelli great work with thx, it's just superb.

@nadako
Copy link
Member Author

nadako commented Apr 25, 2017

Rebased. There's a basic test in EReg.unit.hx. Nowadays I probably need to add support for PHP7 as well, but let's first see if it still passes the tests.

@nadako nadako merged commit f375ec9 into HaxeFoundation:development Apr 25, 2017
@nadako nadako deleted the ereg_escape branch April 25, 2017 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants