Author ezio.melotti
Recipients SilentGhost, amaury.forgeotdarc, belopolsky, benjamin.peterson, bjourne, donlorenzo, ezio.melotti, foom, georg.brandl, mortenlj, mrabarnett, pitrou, rsc, swamiyeswanth, timehorse, zanella
Date 2011-03-14.01:38:11
SpamBayes Score 0.0167095
Marked as misclassified No
Message-id <1300066692.36.0.468357546415.issue2650@psf.upfronthosting.co.za>
In-reply-to
Content
I took a look to what other languages do, and it turned out that:

perl escapes [^A-Za-z_0-9] [0];
.net escapes the metachars and whitespace [1];
java escapes the metachars or escape sequences [2];
ruby escapes the metachars [3];

It might be OK to exclude _ from the escaped chars, but I would keep escaping all the other non-alnum chars too (i.e. match perl behavior).

(FWIW, I don't think re.escape() is used in performance-critical situation, so readability should probably be preferred over speed.)

[0]: http://perldoc.perl.org/functions/quotemeta.html
[1]: http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape.aspx
[2]: http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html
[3]: http://www.ruby-doc.org/core/classes/Regexp.html
History
Date User Action Args
2011-03-14 01:38:12ezio.melottisetrecipients: + ezio.melotti, georg.brandl, amaury.forgeotdarc, belopolsky, foom, pitrou, rsc, timehorse, benjamin.peterson, zanella, donlorenzo, bjourne, mortenlj, mrabarnett, SilentGhost, swamiyeswanth
2011-03-14 01:38:12ezio.melottisetmessageid: <1300066692.36.0.468357546415.issue2650@psf.upfronthosting.co.za>
2011-03-14 01:38:11ezio.melottilinkissue2650 messages
2011-03-14 01:38:11ezio.melotticreate