gnu-regexp should raise?

S

Simon Strandgaard

Why does /[]]/ not raise an exception, when /[]/ does ?


server> ruby -e "p /[]]/.match('a]e').to_a"
-e:1: warning: character class has `]' without escape
["]"]
server> ruby -e "p /[]/.match('a]e').to_a"
-e:1: invalid regular expression; empty character class: /[]/
server>
 
N

Nikolai Weibull

* Simon Strandgaard said:
Why does /[]]/ not raise an exception, when /[]/ does ?
well, it is standard to allow having ] as the first character in a []
character class definition, as the empty character class is usually
illegal. it is, however, not very obvious and so Ruby complains (with a
warning) if it sees one. I'd say that you should go the Perl6 way and
remove character classes defined in this way from you regex library.
That's what I'm going to do.
nikolai
 
S

Simon Strandgaard

* Simon Strandgaard said:
Why does /[]]/ not raise an exception, when /[]/ does ?
well, it is standard to allow having ] as the first character in a []
character class definition, as the empty character class is usually
illegal. it is, however, not very obvious and so Ruby complains (with a
warning) if it sees one. I'd say that you should go the Perl6 way and
remove character classes defined in this way from you regex library.
That's what I'm going to do.
nikolai

Good idea, I will do that.


I have just made my first attempt to exercise my regexp-engine
against the rubicon testsuite, status are:
pass=1202, fail=358, pass/total=77.0512820512821

Interesting experience.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,813
Members
47,357
Latest member
sitele8746

Latest Threads

Top