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

Support Pattern.compile(/regex/) #4803

Closed
wants to merge 1 commit into from
Closed

Conversation

madrob
Copy link
Contributor

@madrob madrob commented Oct 3, 2017

Would like to add tests, but I'm not familiar enough with ruby to know where they go.

@kares
Copy link
Member

kares commented Oct 3, 2017

thanks for your effort,
but I am really not sure about this change - seems like a one off requirement which isn't thought through ...

we're trying to make Java objects more Ruby-like here (posted the link to these on IRC as a hint of what can you expect from JRuby's extension on java.util.regexp).

... the right place for this would be having a /ruby/.to_java to return a java.util.Regexp when requested
but since the Java version is less powerful and does not support lot of the features its still questionable.

@kares
Copy link
Member

kares commented Oct 3, 2017

besides that I am not sure whether it actually works - escaping and potentially flags are not handled?
sorry but this simply needs more work to make it worth looking at.

... its simply just java.util.regexp.Pattern.compile(/ruby/.to_s) without to_s at the end

@madrob
Copy link
Contributor Author

madrob commented Oct 3, 2017

Implementing this as a /ruby/.to_java makes sense, I'll rework it in that direction. What is here now is definitely a WIP, I thought the lack of tests would indicate that it's not ready for commit but should have labelled it explicitly anyway.

The use case for this is when calling java methods that expect a Pattern argument. I understand and agree that Pattern is less powerful than RubyRegexp but having the ability to intelligently downgrade would be useful. Otherwise, users do end up just using to_s with all the rough edges that it may present.

@enebo
Copy link
Member

enebo commented Oct 3, 2017

@madrob you should definitely figure out what behavior (and how to detect it) that should happen when you try and make a pattern which is not possible in Java Regexp. It must be able to explicitly know that it is an invalid regexp or I think it will be confusing.

@kares
Copy link
Member

kares commented May 20, 2018

as agreed this needs a different direction -> seems there isn't much activity so will likely get closed, for now

@kares kares added this to the Invalid or Duplicate milestone May 20, 2018
@madrob madrob closed this Feb 12, 2020
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.

None yet

3 participants