Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Bug in regex engine ?? Must be...
David Krmpotic
3/3/2008 7:24:00 PM
Hi,
I'm using Ruby 1.8.6, and I just discovered something rather
interesting, here is a test:
require 'test/unit'
class TestRegexBug < Test::Unit::TestCase
def test_bug
hours = "pon-Äet"
assert(hours =~ /[Ä]et/i)
assert(hours =~ /Äet/i)
assert(hours =~ /-Äet/i)
assert(hours =~ /[cÄ]et/i)
assert(hours =~ /-[Ä]et/i)
end
end
As you can see, this only happens with unicode letters... (the last test
fails).. I'm used to the fact that //i doesn't work for unicode chars
and I already know that you need two dots to match one of these.. But
this problem is different and weirder, because what triggers it is a
minus sign before the square brackets.. if you remove either the '-' or
'[]' from the regex, it works..
Can you comment?
thank you,
david
--
Posted via
http://www.ruby-...
.
2 Answers
Rob Biedenharn
3/3/2008 10:45:00 PM
0
On Mar 3, 2008, at 2:24 PM, D. Krmpotic wrote:
> Hi,
>
> I'm using Ruby 1.8.6, and I just discovered something rather
> interesting, here is a test:
>
$KCODE =3D 'UTF8'
require 'jcode'
> require 'test/unit'
>
> class TestRegexBug < Test::Unit::TestCase
>
> def test_bug
>
> hours =3D "pon-=C4=8Det"
>
> assert(hours =3D~ /[=C4=8D]et/i)
> assert(hours =3D~ /=C4=8Det/i)
> assert(hours =3D~ /-=C4=8Det/i)
> assert(hours =3D~ /[c=C4=8D]et/i)
> assert(hours =3D~ /-[=C4=8D]et/i)
>
> end
>
> end
>
> As you can see, this only happens with unicode letters... (the last =20=
> test
> fails).. I'm used to the fact that //i doesn't work for unicode chars
> and I already know that you need two dots to match one of these.. But
> this problem is different and weirder, because what triggers it is a
> minus sign before the square brackets.. if you remove either the '-' =20=
> or
> '[]' from the regex, it works..
>
> Can you comment?
>
> thank you,
> david
Ruby is not natively aware of unicode, but you can get all these to =20
pass if you give it the $KCOCDE hint.
-Rob
Rob Biedenharn
http://agileconsult...
Rob@AgileConsultingLLC.com
David Krmpotic
3/7/2008 9:31:00 PM
0
Great info.. completely forgot that this is available...
thank you
david
> $KCODE = 'UTF8'
> require 'jcode'
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Bug in regex engine ?? Must be...
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password