On 26/01/2014 17:25, Chris Angelico wrote:
On Mon, Jan 27, 2014 at 4:15 AM, Roy Smith <r...@panix.com> wrote:
In article <mailman.5996.1390756093.18130.python-l...@python.org>,
  Chris Angelico <ros...@gmail.com> wrote:

The set [A-z] is equivalent to
[ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz]

I'm inclined to suggest the regex compiler should issue a warning for
this.

I've never seen a character range other than A-Z, a-z, or 0-9.  Well, I
suppose A-F or a-f if you're trying to match hex digits (and some
variations on that for octal).  But, I can't imagine any example where
somebody wrote A-z and it wasn't an error.

I've used a variety of character ranges, certainly more than the 4-5
you listed, but I agree that A-z is extremely likely to be an error.
However, I've sometimes used a regex (bytes mode) to find, say, all
the ASCII printable characters - [ -~] - and I wouldn't want that
precluded. It's a bit tricky trying to figure out which are likely to
be errors and which are not, so I'd be inclined to keep things as they
are. No warnings.

ChrisA


I suggest a single warning is always given "Regular expressions can be fickle. Have you considered using string methods?". My apologies to regex fans if they're currently choking over their tea, coffee, cocoa, beer, scotch, saki, ouzo or whatever :)

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to