in reply to Re^3: Quantifier follows nothing error in Regexp::Grammars (hyphen charclass)
in thread Quantifier follows nothing error in Regexp::Grammars

If you write /[:-&]/, you get Invalid [] range ":-&" in regex; marked by <-- HERE in m/[:-& <-- HERE ]/ because ':' comes later in the ASCII table than '&'.

If you write /[&-:]/, it matches each of &'()*+,-./0123456789:, the full range in the ASCII table between ':' and '&'.

If you write /[-&:]/, it matches only one of -&: as the hyphen is not interpreted as a range operator.

Of course, you can escape it with a backslash as well, which is the case in the post above but I had not seen when I first looked at it.

Replies are listed 'Best First'.
Re^5: Quantifier follows nothing error in Regexp::Grammars (hyphen charclass)
by Anonymous Monk on Oct 09, 2013 at 08:50 UTC

    Of course, you can escape it with a backslash as well, which is the case in the post above but I had not seen when I first looked at it.

    Oh, I see :) I thought you might have had some other reasoning ... that maybe excluded backslash ... :) hi guy, its me I am