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

Regex Symbol missing #3603

Closed
digininja opened this issue Jan 18, 2016 · 8 comments
Closed

Regex Symbol missing #3603

digininja opened this issue Jan 18, 2016 · 8 comments

Comments

@digininja
Copy link

I've got the following regex to detect symbols:

if "~" =~ /^[\p{Symbol}]+$/
    puts "match"
end 

It works fine in Ruby but fails with this error in JRuby

SyntaxError: (RegexpError) invalid character property name <Symbol>: /^[\p{Symbol}]+$/

I tried to detect this and use Punct instead but as it is a syntax error I can't get it with a being/rescue.

I've also noticed that Punct in JRuby contains different characters to what are contained in the Ruby version.

So, why is Symbol missing and why is there a difference in the Punct config?

@enebo
Copy link
Member

enebo commented Jan 19, 2016

@digininja Is this reported against JRuby 1.7.23 or JRuby 9k? I see it working on master and I suspect it worked on the last released version (it would be great if you could check so you can also see if the Punct differences have also been fixed). On 1.7.x we support 1.8.7 and 1.9.3 and Symbol did not exist as a character class back then so we also do not support it. Recently we did update our jcodings library for 1.7.x so I am hoping your Punct differences will be correct.

@lopex
Copy link
Contributor

lopex commented Jan 19, 2016

Also, those are available only in unicode, so check your 'coding' magic comment and ENCODING.

@digininja
Copy link
Author

I'm running the latest jruby from rvm

$ ruby -v
jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on OpenJDK 64-Bit Server VM 1.8.0_66-internal-b17 +jit [linux-amd64]

I'll see if I can get a newer version and try it with that.

@lopex I'm not doing anything special with encoding, can you point me at an example of what I should be setting? It works find in MRI.

@lopex
Copy link
Contributor

lopex commented Jan 20, 2016

It might work on MRI if JRuby differs when selecting encoding based on system locales. Can you reassure if that regexp works with //u modifier and/or ENCODING is indeed utf-8. ?

@headius
Copy link
Member

headius commented Jan 21, 2016

This does appear to be a thing in Ruby 1.9.3, and ignored in 1.8.7:

[] ~/projects/jruby-1.7 $ cat blah.rb
# encoding: utf-8
if "~" =~ /^[\p{Symbol}]+$/
    puts "match"
end 

[] ~/projects/jruby-1.7 $ rvm ruby-1.9 do ruby -v blah.rb
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.3.0]
match

[] ~/projects/jruby-1.7 $ rvm ruby-1.8 do ruby -v blah.rb
ruby 1.8.7 (2014-01-28 patchlevel 376) [i686-darwin13.4.0]

[] ~/projects/jruby-1.7 $ 

And it seems like joni updates in JRuby 1.7 have fixed it:

$ rvm jruby-1.7.24 do ruby -v blah.rb
jruby 1.7.24 (1.9.3p551) 2016-01-20 bd68d85 on Java HotSpot(TM) 64-Bit Server VM 9-ea+100-2016-01-06-200131.javare.4235.nc +jit [darwin-x86_64]
match

So...all good :-)

@headius headius closed this as completed Jan 21, 2016
@headius headius added this to the JRuby 1.7.24 milestone Jan 21, 2016
@digininja
Copy link
Author

I'm not at a PC to test this at they moment but are you saying that the
symbol is there in newer versions of jruby?
On 21 Jan 2016 21:14, "Charles Oliver Nutter" notifications@github.com
wrote:

Closed #3603 #3603.


Reply to this email directly or view it on GitHub
#3603 (comment).

@headius
Copy link
Member

headius commented Jan 21, 2016 via email

@digininja
Copy link
Author

OK thanks. I was running the latest from rvm so I'll have to have to force
it to use the newer version.
On 21 Jan 2016 23:21, "Charles Oliver Nutter" notifications@github.com
wrote:

Yes, try the fresh release of 1.7.24 and it should work.


Reply to this email directly or view it on GitHub
#3603 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants