Re: Beautiful Code : Pity he didn't ask here...



On Wed, Jul 11, 2007 at 10:53:42AM +0900, ara.t.howard wrote:
%r|GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/[^ .]+)|x

Looking at all those \d is kind of hard to parse also. I think the following
way of expression that pattern is considerably clearer:

%r|GET /ongoing/When/\d{3}x/(\d{4}/\d{2}/\d{2}/[^ .]+)|x

Readability improves even more when Oniguruma allows for named captures.

marcel
--
Marcel Molina Jr. <marcel@xxxxxxxxxx>

.



Relevant Pages

  • Re: Beautiful Code : Pity he didnt ask here...
    ... way of expression that pattern is considerably clearer: ... Readability improves even more when Oniguruma allows for named captures. ... It is hard to parse. ...
    (comp.lang.ruby)
  • RE: Check value is number only
    ... > more important than readability, and with extensive testing one can ... > dramatically reduce the risk of such a complicated regular expression from ... > While using a Parse() may be simpler and more readable, ... > invalid values are being dealt with, using the Regex method can be in the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: store whole InputStream in a String
    ... > This approach fails seriously on readability. ... As I have already said, once you have seen this pattern ten thousand times, ... Inexperienced programmers will often create something like this: ... This stream might end? ...
    (comp.lang.java.programmer)
  • Re: [ANN] Chronic-0.1.0
    ... See below for the wide variety of formats Chronic will parse. ... I've been wrestling with that concept for ... awhile not in a OS X Dashboard clock I made. ... Which matches a pattern that knows to look for the next future January, and beginning with the start of that month, look for the next future Tuesday three times. ...
    (comp.lang.ruby)
  • RE: Check value is number only
    ... Code readability is always good, however there are times when performance is ... dramatically reduce the risk of such a complicated regular expression from ... While using a Parse() may be simpler and more readable, ... > They also don't perform as well as "brute force" hard coded tests in ...
    (microsoft.public.dotnet.languages.csharp)