Gnu-regexp should raise?

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

ruby -e “p /]/.match(‘a]e’).to_a”
-e:1: warning: character class has `]’ without escape
[“]”]
ruby -e “p //.match(‘a]e’).to_a”
-e:1: invalid regular expression; empty character class: //

···


Simon Strandgaard

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

···


::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux[“\021%six\012\0”],(linux)[“have”]+“fun”-97);}

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.

···

On Thu, 27 Nov 2003 04:34:54 +0900, Nikolai Weibull wrote:

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


Simon Strandgaard